Zebediah Figura : winegstreamer: Avoid leaking a newly allocated buffer on failure in request_buffer_src().
Alexandre Julliard
julliard at winehq.org
Fri Sep 25 14:52:53 CDT 2020
Module: wine
Branch: master
Commit: 025b3de29c63e5a05f66bd5354d7e90c2ccad417
URL: https://source.winehq.org/git/wine.git/?a=commit;h=025b3de29c63e5a05f66bd5354d7e90c2ccad417
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Thu Sep 24 22:22:55 2020 -0500
winegstreamer: Avoid leaking a newly allocated buffer on failure in request_buffer_src().
According to the GStreamer documentation, the contents of "buffer" should be
considered undefined on failure, which means that the caller has no way of
freeing a newly allocated buffer.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winegstreamer/gstdemux.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index 9a9fe01936..acb15dc923 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -878,13 +878,14 @@ static GstFlowReturn got_data_sink(GstPad *pad, GstObject *parent, GstBuffer *bu
return GST_FLOW_OK;
}
-static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 ofs, guint len, GstBuffer **buf)
+static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 ofs, guint len, GstBuffer **buffer)
{
struct gstdemux *This = gst_pad_get_element_private(pad);
+ GstBuffer *new_buffer = NULL;
HRESULT hr;
GstMapInfo info;
- TRACE("pad %p, offset %s, length %u, buffer %p.\n", pad, wine_dbgstr_longlong(ofs), len, *buf);
+ TRACE("pad %p, offset %s, length %u, buffer %p.\n", pad, wine_dbgstr_longlong(ofs), len, *buffer);
if (ofs == GST_BUFFER_OFFSET_NONE)
ofs = This->nextpullofs;
@@ -896,13 +897,16 @@ static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64
len = This->filesize - ofs;
This->nextpullofs = ofs + len;
- if (!*buf)
- *buf = gst_buffer_new_and_alloc(len);
- gst_buffer_map(*buf, &info, GST_MAP_WRITE);
+ if (!*buffer)
+ *buffer = new_buffer = gst_buffer_new_and_alloc(len);
+ gst_buffer_map(*buffer, &info, GST_MAP_WRITE);
hr = IAsyncReader_SyncRead(This->reader, ofs, len, info.data);
- gst_buffer_unmap(*buf, &info);
- if (FAILED(hr)) {
- ERR("Returned %08x\n", hr);
+ gst_buffer_unmap(*buffer, &info);
+ if (FAILED(hr))
+ {
+ ERR("Failed to read data, hr %#x.\n", hr);
+ if (new_buffer)
+ gst_buffer_unref(new_buffer);
return GST_FLOW_ERROR;
}
More information about the wine-cvs
mailing list