Takashi Iwai <tiwai@suse.de>

Don't loop infinitely on recursive symlinks (client-side).
This commit is contained in:
Patrick Lam 2006-02-07 02:22:50 +00:00
parent 660acf8f22
commit 8b413bb62c
2 changed files with 22 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2006-02-06 Patrick Lam <plam@mit.edu>
Takashi Iwai <tiwai@suse.de>
* src/fccache.c (FcCacheReadDirs, FcCacheRead):
Don't loop infinitely on recursive symlinks (client-side).
2006-02-06 Takashi Iwai <tiwai@suse.de> 2006-02-06 Takashi Iwai <tiwai@suse.de>
reviewed by: plam reviewed by: plam
* fc-cache/fc-cache.c (scanDirs, main): * fc-cache/fc-cache.c (scanDirs, main):

View File

@ -863,7 +863,7 @@ FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
static int static int
FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache, FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache,
FcStrList *list, FcFontSet * set) FcStrList *list, FcFontSet * set, FcStrSet *processed_dirs)
{ {
int ret = 0; int ret = 0;
FcChar8 *dir; FcChar8 *dir;
@ -887,9 +887,9 @@ FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache,
name = FcConfigNormalizeFontDir (config, dir); name = FcConfigNormalizeFontDir (config, dir);
if (name) if (name)
{ {
if ((d = FcGlobalCacheDirFind (cache, (const char *)name)) != NULL && if (FcStrSetMember (processed_dirs, dir))
d->state == FcGCDirUpdated)
continue; continue;
FcStrSetAdd (processed_dirs, dir);
} }
subdirs = FcStrSetCreate (); subdirs = FcStrSetCreate ();
@ -955,7 +955,7 @@ FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache,
ret++; ret++;
continue; continue;
} }
ret += FcCacheReadDirs (config, cache, sublist, set); ret += FcCacheReadDirs (config, cache, sublist, set, processed_dirs);
} }
FcStrListDone (list); FcStrListDone (list);
return ret; return ret;
@ -965,14 +965,23 @@ FcFontSet *
FcCacheRead (FcConfig *config, FcGlobalCache * cache) FcCacheRead (FcConfig *config, FcGlobalCache * cache)
{ {
FcFontSet *s = FcFontSetCreate(); FcFontSet *s = FcFontSetCreate();
FcStrSet *processed_dirs;
if (!s) if (!s)
return 0; return 0;
if (FcCacheReadDirs (config, cache, FcConfigGetConfigDirs (config), s)) processed_dirs = FcStrSetCreate();
if (!processed_dirs)
goto bail; goto bail;
if (FcCacheReadDirs (config, cache, FcConfigGetConfigDirs (config), s, processed_dirs))
goto bail1;
FcStrSetDestroy (processed_dirs);
return s; return s;
bail1:
FcStrSetDestroy (processed_dirs);
bail: bail:
FcFontSetDestroy (s); FcFontSetDestroy (s);
return 0; return 0;