[PATCH] winegstreamer: Clean up a newly allocated buffer on error in bytestream_wrapper_pull().

Zebediah Figura z.figura12 at gmail.com
Sat Dec 5 10:32:17 CST 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/winegstreamer/media_source.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index d411bbd1de2..ffbf8041ed8 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -443,6 +443,7 @@ GstFlowReturn bytestream_wrapper_pull(GstPad *pad, GstObject *parent, guint64 of
 {
     struct media_source *source = gst_pad_get_element_private(pad);
     IMFByteStream *byte_stream = source->byte_stream;
+    GstBuffer *new_buffer = NULL;
     ULONG bytes_read;
     GstMapInfo info;
     BOOL is_eof;
@@ -463,7 +464,7 @@ GstFlowReturn bytestream_wrapper_pull(GstPad *pad, GstObject *parent, guint64 of
         return GST_FLOW_EOS;
 
     if (!(*buf))
-        *buf = gst_buffer_new_and_alloc(len);
+        *buf = new_buffer = gst_buffer_new_and_alloc(len);
     gst_buffer_map(*buf, &info, GST_MAP_WRITE);
     hr = IMFByteStream_Read(byte_stream, info.data, len, &bytes_read);
     gst_buffer_unmap(*buf, &info);
@@ -471,7 +472,11 @@ GstFlowReturn bytestream_wrapper_pull(GstPad *pad, GstObject *parent, guint64 of
     gst_buffer_set_size(*buf, bytes_read);
 
     if (FAILED(hr))
+    {
+        if (new_buffer)
+            gst_buffer_unref(new_buffer);
         return GST_FLOW_ERROR;
+    }
     return GST_FLOW_OK;
 }
 
-- 
2.29.2




More information about the wine-devel mailing list