[PATCH 2/2] winegstreamer: Avoid leaking a newly allocated buffer on failure in request_buffer_src().
Zebediah Figura
z.figura12 at gmail.com
Thu Sep 24 11:37:00 CDT 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
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 9a9fe01936b..acb15dc9238 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;
}
--
2.28.0
More information about the wine-devel
mailing list