Fix two memory leaks discovered with Valgrind.
authorDmitry Antipov <dmantipov@yandex.ru>
Thu, 23 Jan 2014 12:18:08 +0000 (16:18 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Thu, 23 Jan 2014 12:18:08 +0000 (16:18 +0400)
* ftfont.c (ftfont_list) [HAVE_LIBOTF]: Call OTF_close.
* image.c (Fimagemagick_types): Call MagickRelinquishMemory.

src/ChangeLog
src/ftfont.c
src/image.c

index a9822e5..5d01b8e 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-23  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Fix two memory leaks discovered with Valgrind.
+       * ftfont.c (ftfont_list) [HAVE_LIBOTF]: Call OTF_close.
+       * image.c (Fimagemagick_types): Call MagickRelinquishMemory.
+
 2014-01-22  Martin Rudalics  <rudalics@gmx.at>
 
        Fixes in window size functions around Bug#16430 and Bug#16470.
index 3849897..112adad 100644 (file)
@@ -1011,6 +1011,7 @@ ftfont_list (struct frame *f, Lisp_Object spec)
       if (otspec)
        {
          FcChar8 *file;
+         bool passed;
          OTF *otf;
 
          if (FcPatternGetString (fontset->fonts[i], FC_FILE, 0, &file)
@@ -1019,14 +1020,16 @@ ftfont_list (struct frame *f, Lisp_Object spec)
          otf = OTF_open ((char *) file);
          if (! otf)
            continue;
-         if (OTF_check_features (otf, 1,
-                                 otspec->script_tag, otspec->langsys_tag,
-                                 otspec->features[0],
-                                 otspec->nfeatures[0]) != 1
-             || OTF_check_features (otf, 0,
-                                    otspec->script_tag, otspec->langsys_tag,
-                                    otspec->features[1],
-                                    otspec->nfeatures[1]) != 1)
+         passed = (OTF_check_features (otf, 1, otspec->script_tag,
+                                       otspec->langsys_tag,
+                                       otspec->features[0],
+                                       otspec->nfeatures[0]) == 1
+                   && OTF_check_features (otf, 0, otspec->script_tag,
+                                          otspec->langsys_tag,
+                                          otspec->features[1],
+                                          otspec->nfeatures[1]) == 1);
+         OTF_close (otf);
+         if (!passed)
            continue;
        }
 #endif /* HAVE_LIBOTF */
index 63f97fe..e4f4c7e 100644 (file)
@@ -8546,7 +8546,10 @@ and `imagemagick-types-inhibit'.  */)
     {
       Qimagemagicktype = intern (imtypes[i]);
       typelist = Fcons (Qimagemagicktype, typelist);
+      imtypes[i] = (char *) MagickRelinquishMemory (imtypes[i]);
     }
+
+  imtypes = (char **) MagickRelinquishMemory (imtypes);
   return Fnreverse (typelist);
 }