Commits

tabe  committed cfc733a

decrement the pattern reference count in case of failure.

  • Participants
  • Parent commits 35b7d24
  • Branches GD-2.0

Comments (0)

Files changed (1)

       font = find_font(pattern);
       FcPatternDestroy(pattern);
 
-      if (!font || FcPatternGetString(font, FC_FAMILY, 0, &family) != FcResultMatch)
-	return "fontconfig: Couldn't retrieve font family name.";
+      if (!font)
+        return "fontconfig: Couldn't find font.";
+      if (FcPatternGetString(font, FC_FAMILY, 0, &family) != FcResultMatch) {
+        FcPatternDestroy(font);
+        return "fontconfig: Couldn't retrieve font family name.";
+      }
       
       /* Check whether we got the font family we wanted. */
       if (strcmp((const char *)family, postscript_alias[i].family) != 0) {
   }
 #endif
 
-  if (!font || FcPatternGetString(font, FC_FILE, 0, &file) != FcResultMatch)
+  if (!font)
+    return "fontconfig: Couldn't find font.";
+  if (FcPatternGetString(font, FC_FILE, 0, &file) != FcResultMatch) {
+    FcPatternDestroy(font);
     return "fontconfig: Couldn't retrieve font file name.";
+  }
 
   *fontpath = strdup((const char *)file);