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@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
622f2ce991
commit
025b3de29c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue