[FFmpeg-cvslog] avfilter/vf_drawtext: fix resource leak

Leandro Santiago git at videolan.org
Thu Jul 3 15:45:35 CEST 2014


ffmpeg | branch: master | Leandro Santiago <leandrosansilva at gmail.com> | Wed Jul  2 09:39:50 2014 -0300| [4582e1162a0b57bd0787da390555b8f96f8b393b] | committer: Michael Niedermayer

avfilter/vf_drawtext: fix resource leak

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4582e1162a0b57bd0787da390555b8f96f8b393b
---

 libavfilter/vf_drawtext.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index adc587e..202b2fa 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -262,6 +262,7 @@ struct ft_error
 
 typedef struct Glyph {
     FT_Glyph *glyph;
+    FT_Glyph border_glyph;
     uint32_t code;
     FT_Bitmap bitmap; ///< array holding bitmaps of font
     FT_Bitmap border_bitmap; ///< array holding bitmaps of font border
@@ -306,13 +307,13 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
         goto error;
     }
     if (s->borderw) {
-        FT_Glyph border_glyph = *glyph->glyph;
-        if (FT_Glyph_StrokeBorder(&border_glyph, s->stroker, 0, 0) ||
-            FT_Glyph_To_Bitmap(&border_glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
+        glyph->border_glyph = *glyph->glyph;
+        if (FT_Glyph_StrokeBorder(&glyph->border_glyph, s->stroker, 0, 0) ||
+            FT_Glyph_To_Bitmap(&glyph->border_glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
             ret = AVERROR_EXTERNAL;
             goto error;
         }
-        bitmapglyph = (FT_BitmapGlyph) border_glyph;
+        bitmapglyph = (FT_BitmapGlyph) glyph->border_glyph;
         glyph->border_bitmap = bitmapglyph->bitmap;
     }
     if (FT_Glyph_To_Bitmap(glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
@@ -343,6 +344,7 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
 error:
     if (glyph)
         av_freep(&glyph->glyph);
+
     av_freep(&glyph);
     av_freep(&node);
     return ret;
@@ -584,6 +586,7 @@ static int glyph_enu_free(void *opaque, void *elem)
     Glyph *glyph = elem;
 
     FT_Done_Glyph(*glyph->glyph);
+    FT_Done_Glyph(glyph->border_glyph);
     av_freep(&glyph->glyph);
     av_free(elem);
     return 0;



More information about the ffmpeg-cvslog mailing list