diff options
author | Patrick Lam <plam@MIT.EDU> | 2006-02-06 23:11:41 +0000 |
---|---|---|
committer | Patrick Lam <plam@MIT.EDU> | 2006-02-06 23:11:41 +0000 |
commit | 660acf8f2278df9276c9a1bff3533e9a74fd8c6b (patch) | |
tree | e8c056614d62708e55fea7828c82ff860f328878 /fc-cache | |
parent | fff5a5af30142c933d8e9dddda61a6a994f44c28 (diff) |
Don't loop infinitely on recursive symlinks.
reviewed by: plam
Diffstat (limited to 'fc-cache')
-rw-r--r-- | fc-cache/fc-cache.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c index f93a085..c4cca32 100644 --- a/fc-cache/fc-cache.c +++ b/fc-cache/fc-cache.c @@ -93,6 +93,8 @@ usage (char *program) exit (1); } +static FcStrSet *processed_dirs; + static int nsubdirs (FcStrSet *set) { @@ -140,6 +142,12 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool continue; } + if (FcStrSetMember (processed_dirs, dir)) + { + if (verbose) + printf ("skipping, looped directory detected\n"); + continue; + } set = FcFontSetCreate (); if (!set) @@ -236,6 +244,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool ret++; continue; } + FcStrSetAdd (processed_dirs, dir); ret += scanDirs (sublist, config, program, force, verbose); } FcStrListDone (list); @@ -318,7 +327,16 @@ main (int argc, char **argv) } else list = FcConfigGetConfigDirs (config); + + if ((processed_dirs = FcStrSetCreate()) == NULL) { + fprintf(stderr, "Cannot malloc\n"); + return 1; + } + ret = scanDirs (list, config, argv[0], force, verbose); + + FcStrSetDestroy (processed_dirs); + /* * Now we need to sleep a second (or two, to be extra sure), to make * sure that timestamps for changes after this run of fc-cache are later |