mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
wavparse: Avoid occasional crash due to referencing freed buffer.
We've seen occasional crashes in the `wavparse` module associated with referencing a buffer in `gst_wavparse_chain` that's already been freed. The reference is stolen when the buffer is transferred to the adapter with `gst_adapter_push` and, IIUC, assuming the source doesn't hold a reference to the buffer, the buffer could be freed during interaction with the adapter in `gst_wavparse_stream_headers`. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3179>
This commit is contained in:
parent
ae8a5e110c
commit
31b244271e
1 changed files with 8 additions and 1 deletions
|
@ -2333,6 +2333,11 @@ gst_wavparse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
GST_LOG_OBJECT (wav, "adapter_push %" G_GSIZE_FORMAT " bytes",
|
GST_LOG_OBJECT (wav, "adapter_push %" G_GSIZE_FORMAT " bytes",
|
||||||
gst_buffer_get_size (buf));
|
gst_buffer_get_size (buf));
|
||||||
|
|
||||||
|
/* Hold a reference to the buffer, as we access buffer properties in the
|
||||||
|
`GST_WAVPARSE_DATA` case below and `gst_adapter_push` steals a reference
|
||||||
|
to the buffer. */
|
||||||
|
gst_buffer_ref (buf);
|
||||||
|
|
||||||
gst_adapter_push (wav->adapter, buf);
|
gst_adapter_push (wav->adapter, buf);
|
||||||
|
|
||||||
switch (wav->state) {
|
switch (wav->state) {
|
||||||
|
@ -2364,7 +2369,7 @@ gst_wavparse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
goto done;
|
goto done;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_return_val_if_reached (GST_FLOW_ERROR);
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
if (G_UNLIKELY (wav->abort_buffering)) {
|
if (G_UNLIKELY (wav->abort_buffering)) {
|
||||||
|
@ -2374,6 +2379,8 @@ done:
|
||||||
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL), ("unhandled buffer size"));
|
GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL), ("unhandled buffer size"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue