| This patch fixes an issue where the wrong file path was passed to stat when |
| the --sysroot argument was used. |
| |
| diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c |
| index 87e3020..9902093 100644 |
| --- a/fc-cache/fc-cache.c |
| +++ b/fc-cache/fc-cache.c |
| @@ -142,6 +142,7 @@ 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 |
| @@ -156,7 +157,18 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, |
| printf ("%s: ", dir); |
| 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) |
| @@ -164,7 +176,7 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, |
| continue; |
| } |
| |
| - if (stat ((char *) dir, &statb) == -1) |
| + if (stat ((char *) rooted_dir, &statb) == -1) |
| { |
| switch (errno) { |
| case ENOENT: |
| @@ -259,6 +271,9 @@ scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, |
| ret += scanDirs (sublist, config, force, really_force, verbose, error_on_no_fonts, changed); |
| FcStrListDone (sublist); |
| } |
| + if (rooted_dir) { |
| + FcStrFree(rooted_dir); |
| + } |
| if (error_on_no_fonts && !was_processed) |
| ret++; |
| return ret; |