From 1ac2218467260cc2f96f202910ba2e1a97291744 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Thu, 19 Jul 2018 07:50:20 +0000 Subject: [PATCH] do not pass null pointer to memcpy --- src/fccfg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fccfg.c b/src/fccfg.c index 31ed238..3d0356a 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -2109,7 +2109,8 @@ FcConfigXdgCacheHome (void) ret = malloc (len + 7 + 1); if (ret) { - memcpy (ret, home, len); + if (home) + memcpy (ret, home, len); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".cache", 7); ret[len + 7] = 0; } @@ -2136,7 +2137,8 @@ FcConfigXdgConfigHome (void) ret = malloc (len + 8 + 1); if (ret) { - memcpy (ret, home, len); + if (home) + memcpy (ret, home, len); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".config", 8); ret[len + 8] = 0; } @@ -2163,7 +2165,8 @@ FcConfigXdgDataHome (void) ret = malloc (len + 13 + 1); if (ret) { - memcpy (ret, home, len); + if (home) + memcpy (ret, home, len); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".local" FC_DIR_SEPARATOR_S "share", 13); ret[len + 13] = 0; }