[alsa-devel] [PATCH 3/3] topology: Check address and length before string copy

mengdong.lin at linux.intel.com mengdong.lin at linux.intel.com
Tue Jul 19 10:52:48 CEST 2016


From: Mengdong Lin <mengdong.lin at linux.intel.com>

Signed-off-by: Mengdong Lin <mengdong.lin at linux.intel.com>

diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index 4d79aa7..cfde4cc 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -253,6 +253,9 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
 
 static inline void elem_copy_text(char *dest, const char *src, int len)
 {
+	if (!dest || !src || !len)
+		return;
+
 	strncpy(dest, src, len);
 	dest[len - 1] = 0;
 }
-- 
2.5.0



More information about the Alsa-devel mailing list