Re: patch to fix endless loop in fc-cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mike FABIAN <mfabian@xxxxxxx> さんは書きました:

> by Takashi Iwai <tiwai@xxxxxxx>.
>
> fc-cache did loop endless if a subdirectory was a symlink
> pointing to a directory higher up, e.g.
> ln -s /usr/share/fonts /usr/share/fonts/ttt

In addition to that patch for "fc-cache.c", another, similar patch
is also necessary for "fccache.c", otherwise applications using
fontconfig will still loop.

The patch attached is also by Takashi Iwai <tiwai@xxxxxxx>.

--- src/fccache.c-dist	2006-02-06 15:41:37.000000000 +0100
+++ src/fccache.c	2006-02-06 15:45:34.000000000 +0100
@@ -856,6 +856,8 @@ FcDirCacheUnlink (const FcChar8 *dir, Fc
     return FcFalse;
 }
 
+static FcStrSet *processed_dirs;
+
 static int
 FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache, 
 		 FcStrList *list, FcFontSet * set)
@@ -876,14 +878,12 @@ FcCacheReadDirs (FcConfig * config, FcGl
 	if (!FcConfigAcceptFilename (config, dir))
 	    continue;
 
-	/* Skip this directory if already updated
-	 * to avoid the looped directories via symlinks
-	 */
+	/* Skip this directory if already scanned */
 	name = FcConfigNormalizeFontDir (config, dir);
 	if (name) {
-	    if ((d = FcGlobalCacheDirFind (cache, (const char *)name)) != NULL &&
-		d->state == FcGCDirUpdated)
+	    if (FcStrSetMember (processed_dirs, dir))
 		continue;
+	    FcStrSetAdd (processed_dirs, dir);
 	}
 
 	subdirs = FcStrSetCreate ();
@@ -961,12 +961,19 @@ FcCacheRead (FcConfig *config, FcGlobalC
     if (!s) 
 	return 0;
 
+    if ((processed_dirs = FcStrSetCreate()) == NULL) {
+	fprintf(stderr, "Cannot malloc\n");
+	return NULL;
+    }
+
     if (FcCacheReadDirs (config, cache, FcConfigGetConfigDirs (config), s))
 	goto bail;
 
+    FcStrSetDestroy (processed_dirs);
     return s;
 
  bail:
+    FcStrSetDestroy (processed_dirs);
     FcFontSetDestroy (s);
     return 0;
 }
-- 
Mike FABIAN   <mfabian@xxxxxxx>   http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux