[PATCH v2 1/2] winegstreamer: Fix memory leaks in amt_from_gst_caps_video.

Alex Henrie alexhenrie24 at gmail.com
Tue Nov 15 23:41:49 CST 2016


Cc: Andrew Eikum <aeikum at codeweavers.com>

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/winegstreamer/gstdemux.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index a6a41ab..892385f 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -179,18 +179,21 @@ static gboolean amt_from_gst_caps_audio(GstCaps *caps, AM_MEDIA_TYPE *amt)
 
 static gboolean amt_from_gst_caps_video(GstCaps *caps, AM_MEDIA_TYPE *amt)
 {
-    VIDEOINFOHEADER *vih = CoTaskMemAlloc(sizeof(*vih));
-    BITMAPINFOHEADER *bih = &vih->bmiHeader;
+    VIDEOINFOHEADER *vih;
+    BITMAPINFOHEADER *bih;
     gint32 width = 0, height = 0, nom = 0, denom = 0;
     GstVideoInfo vinfo;
 
     if (!gst_video_info_from_caps (&vinfo, caps))
         return FALSE;
     width = vinfo.width;
     height = vinfo.height;
     nom = vinfo.fps_n;
     denom = vinfo.fps_d;
 
+    vih = CoTaskMemAlloc(sizeof(*vih));
+    bih = &vih->bmiHeader;
+
     amt->formattype = FORMAT_VideoInfo;
     amt->pbFormat = (BYTE*)vih;
     amt->cbFormat = sizeof(*vih);
@@ -207,13 +210,16 @@ static gboolean amt_from_gst_caps_video(GstCaps *caps, AM_MEDIA_TYPE *amt)
             case 32: amt->subtype = MEDIASUBTYPE_RGB32; break;
             default:
                 FIXME("Unknown bpp %u\n", bih->biBitCount);
+                CoTaskMemFree(vih);
                 return FALSE;
         }
         bih->biCompression = BI_RGB;
     } else {
         amt->subtype = MEDIATYPE_Video;
-        if (!(amt->subtype.Data1 = gst_video_format_to_fourcc(vinfo.finfo->format)))
+        if (!(amt->subtype.Data1 = gst_video_format_to_fourcc(vinfo.finfo->format))) {
+            CoTaskMemFree(vih);
             return FALSE;
+        }
         switch (amt->subtype.Data1) {
             case mmioFOURCC('I','4','2','0'):
             case mmioFOURCC('Y','V','1','2'):
@@ -269,7 +275,8 @@ static gboolean accept_caps_sink(GstPad *pad, GstCaps *caps)
             return FALSE;
         }
         ret = amt_from_gst_caps_video(caps, &amt);
-        FreeMediaType(&amt);
+        if (ret)
+            FreeMediaType(&amt);
         TRACE("-%i\n", ret);
         return ret;
     } else {
-- 
2.10.2




More information about the wine-patches mailing list