patch to fix endless loop in fc-cache

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

 



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

--- fc-cache/fc-cache.c-dist	2006-02-03 12:04:17.000000000 +0100
+++ fc-cache/fc-cache.c	2006-02-03 12:14:33.000000000 +0100
@@ -96,6 +96,8 @@ usage (char *program)
     exit (1);
 }
 
+static FcStrSet *processed_dirs;
+
 static int
 nsubdirs (FcStrSet *set)
 {
@@ -143,6 +145,12 @@ scanDirs (FcStrList *list, FcConfig *con
 	    continue;
 	}
 	
+	if (FcStrSetMember (processed_dirs, dir))
+	{
+	    if (verbose)
+		printf ("skipping, looped directory detected\n");
+	    continue;
+	}
 
 	set = FcFontSetCreate ();
 	if (!set)
@@ -239,6 +247,7 @@ scanDirs (FcStrList *list, FcConfig *con
 	    ret++;
 	    continue;
 	}
+	FcStrSetAdd (processed_dirs, dir);
 	ret += scanDirs (sublist, config, program, force, verbose);
     }
     FcStrListDone (list);
@@ -322,7 +331,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
-- 
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