mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
buffer: avoid memory leaks
Avoid leaking the caps of the dest buffer and avoid doing needless caps refs. When the source and target buffers are the same, return immediatly.
This commit is contained in:
parent
4e8f547f98
commit
791fa43812
1 changed files with 5 additions and 4 deletions
|
@ -193,6 +193,10 @@ gst_buffer_copy_metadata (GstBuffer * dest, const GstBuffer * src,
|
||||||
g_return_if_fail (dest != NULL);
|
g_return_if_fail (dest != NULL);
|
||||||
g_return_if_fail (src != NULL);
|
g_return_if_fail (src != NULL);
|
||||||
|
|
||||||
|
/* nothing to copy if the buffers are the same */
|
||||||
|
if (G_UNLIKELY (dest == src))
|
||||||
|
return;
|
||||||
|
|
||||||
GST_CAT_LOG (GST_CAT_BUFFER, "copy %p to %p", src, dest);
|
GST_CAT_LOG (GST_CAT_BUFFER, "copy %p to %p", src, dest);
|
||||||
|
|
||||||
if (flags & GST_BUFFER_COPY_FLAGS) {
|
if (flags & GST_BUFFER_COPY_FLAGS) {
|
||||||
|
@ -214,10 +218,7 @@ gst_buffer_copy_metadata (GstBuffer * dest, const GstBuffer * src,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & GST_BUFFER_COPY_CAPS) {
|
if (flags & GST_BUFFER_COPY_CAPS) {
|
||||||
if (GST_BUFFER_CAPS (src))
|
gst_caps_replace (&GST_BUFFER_CAPS (dest), GST_BUFFER_CAPS (src));
|
||||||
GST_BUFFER_CAPS (dest) = gst_caps_ref (GST_BUFFER_CAPS (src));
|
|
||||||
else
|
|
||||||
GST_BUFFER_CAPS (dest) = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue