From 565935c89fb5332d8742b9d0f9f6431c359a2e15 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 23 Jan 2014 16:18:08 +0400 Subject: [PATCH] Fix two memory leaks discovered with Valgrind. * ftfont.c (ftfont_list) [HAVE_LIBOTF]: Call OTF_close. * image.c (Fimagemagick_types): Call MagickRelinquishMemory. --- src/ChangeLog | 6 ++++++ src/ftfont.c | 19 +++++++++++-------- src/image.c | 3 +++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a9822e56ac..5d01b8e9f1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-01-23 Dmitry Antipov + + 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 Fixes in window size functions around Bug#16430 and Bug#16470. diff --git a/src/ftfont.c b/src/ftfont.c index 384989732e..112adad8a1 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -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 */ diff --git a/src/image.c b/src/image.c index 63f97fe2ef..e4f4c7ec21 100644 --- a/src/image.c +++ b/src/image.c @@ -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); } -- 2.20.1