From 3c75a5a9358ae570230c324917a636947748eb1f Mon Sep 17 00:00:00 2001 From: Chris McDonald Date: Mon, 26 Nov 2018 11:46:21 -0700 Subject: [PATCH] Lowered temporary rooted_dir variable inside loop --- fc-cache/fc-cache.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c index 61dd57d..71cb61f 100644 --- a/fc-cache/fc-cache.c +++ b/fc-cache/fc-cache.c @@ -142,7 +142,6 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool was_valid, was_processed = FcFalse; int i; const FcChar8 *sysroot = FcConfigGetSysRoot (config); - FcChar8 *rooted_dir = NULL; /* * Now scan all of the directories into separate databases @@ -158,20 +157,6 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, fflush (stdout); } - if (rooted_dir) - { - FcStrFree(rooted_dir); - rooted_dir = NULL; - } - - if (sysroot) - { - rooted_dir = FcStrPlus(sysroot, dir); - } - else { - rooted_dir = FcStrCopy(dir); - } - if (FcStrSetMember (processed_dirs, dir)) { if (verbose) @@ -179,6 +164,15 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, continue; } + FcChar8 *rooted_dir = NULL; + if (sysroot) + { + rooted_dir = FcStrPlus(sysroot, dir); + } + else { + rooted_dir = FcStrCopy(dir); + } + if (stat ((char *) rooted_dir, &statb) == -1) { switch (errno) { @@ -196,6 +190,9 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, continue; } + FcStrFree(rooted_dir); + rooted_dir = NULL; + if (!S_ISDIR (statb.st_mode)) { fprintf (stderr, _("\"%s\": not a directory, skipping\n"), dir); @@ -275,10 +272,6 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcStrListDone (sublist); } - if (rooted_dir) - { - FcStrFree(rooted_dir); - } if (error_on_no_fonts && !was_processed) ret++; return ret;