mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-31 20:48:56 +00:00
bitwriter: Fix a memory leak in reset_and_get_buffer.
We should record the ownership of the data before we reset the bitwriter. Or we will always dup the buffer data and leak the memory. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1272>
This commit is contained in:
parent
68f6730221
commit
6be57e4247
1 changed files with 4 additions and 1 deletions
|
@ -223,15 +223,18 @@ gst_bit_writer_reset_and_get_buffer (GstBitWriter * bitwriter)
|
|||
GstBuffer *buffer;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
gboolean owned;
|
||||
|
||||
g_return_val_if_fail (bitwriter != NULL, NULL);
|
||||
|
||||
owned = bitwriter->owned;
|
||||
|
||||
size = GST_ROUND_UP_8 (bitwriter->bit_size) >> 3;
|
||||
data = gst_bit_writer_reset_and_get_data (bitwriter);
|
||||
|
||||
/* we cannot rely on buffers allocated externally, thus let's dup
|
||||
* the data */
|
||||
if (data && !bitwriter->owned)
|
||||
if (data && !owned)
|
||||
data = g_memdup (data, size);
|
||||
|
||||
buffer = gst_buffer_new ();
|
||||
|
|
Loading…
Reference in a new issue