do not pass null pointer to memcpy

This commit is contained in:
Akira TAGOH 2018-07-19 07:50:20 +00:00
parent f3981a8bcd
commit 1ac2218467
1 changed files with 6 additions and 3 deletions

View File

@ -2109,6 +2109,7 @@ FcConfigXdgCacheHome (void)
ret = malloc (len + 7 + 1); ret = malloc (len + 7 + 1);
if (ret) if (ret)
{ {
if (home)
memcpy (ret, home, len); memcpy (ret, home, len);
memcpy (&ret[len], FC_DIR_SEPARATOR_S ".cache", 7); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".cache", 7);
ret[len + 7] = 0; ret[len + 7] = 0;
@ -2136,6 +2137,7 @@ FcConfigXdgConfigHome (void)
ret = malloc (len + 8 + 1); ret = malloc (len + 8 + 1);
if (ret) if (ret)
{ {
if (home)
memcpy (ret, home, len); memcpy (ret, home, len);
memcpy (&ret[len], FC_DIR_SEPARATOR_S ".config", 8); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".config", 8);
ret[len + 8] = 0; ret[len + 8] = 0;
@ -2163,6 +2165,7 @@ FcConfigXdgDataHome (void)
ret = malloc (len + 13 + 1); ret = malloc (len + 13 + 1);
if (ret) if (ret)
{ {
if (home)
memcpy (ret, home, len); memcpy (ret, home, len);
memcpy (&ret[len], FC_DIR_SEPARATOR_S ".local" FC_DIR_SEPARATOR_S "share", 13); memcpy (&ret[len], FC_DIR_SEPARATOR_S ".local" FC_DIR_SEPARATOR_S "share", 13);
ret[len + 13] = 0; ret[len + 13] = 0;