X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=src%2Ffcstr.c;h=33090140b4fc799a22212470316a8c6742015aca;hb=9b511b290548ad2920cda94507a3311efc461e8a;hp=37bad6b16379f4cd5cf7128d3b163d5eae5d54e6;hpb=0d9e31c810a36cddadff7572fdbb5a1b505e495e;p=fontconfig.git diff --git a/src/fcstr.c b/src/fcstr.c index 37bad6b..3309014 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -764,26 +764,21 @@ FcStrCopyFilename (const FcChar8 *s) if (*s == '~') { FcChar8 *home = FcConfigHome (); + FcChar8 *full; int size; if (!home) return 0; size = strlen ((char *) home) + strlen ((char *) s); - new = (FcChar8 *) malloc (size); + full = (FcChar8 *) malloc (size); if (!new) return 0; - FcMemAlloc (FC_MEM_STRING, size); - strcpy ((char *) new, (char *) home); - strcat ((char *) new, (char *) s + 1); + strcpy ((char *) full, (char *) home); + strcat ((char *) full, (char *) s + 1); + new = FcStrCanonFilename (full); + free (full); } else - { - int size = strlen ((char *) s) + 1; - new = (FcChar8 *) malloc (size); - if (!new) - return 0; - FcMemAlloc (FC_MEM_STRING, size); - memcpy (new, s, size); - } + new = FcStrCanonFilename (s); return new; } @@ -841,6 +836,7 @@ FcStrCanonFilename (const FcChar8 *s) FcChar8 *file; FcChar8 *f; const FcChar8 *slash; + int size; if (*s != '/') { @@ -855,9 +851,11 @@ FcStrCanonFilename (const FcChar8 *s) FcStrFree (full); return file; } - file = malloc (strlen ((char *) s) + 1); + size = strlen ((char *) s) + 1; + file = malloc (size); if (!file) return NULL; + FcMemAlloc (FC_MEM_STRING, size); slash = NULL; f = file; for (;;) { @@ -1052,3 +1050,4 @@ FcStrListDone (FcStrList *list) FcMemFree (FC_MEM_STRLIST, sizeof (FcStrList)); free (list); } +