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:
Wim Taymans 2009-05-27 16:17:31 +02:00
parent 4e8f547f98
commit 791fa43812

View file

@ -193,6 +193,10 @@ gst_buffer_copy_metadata (GstBuffer * dest, const GstBuffer * src,
g_return_if_fail (dest != 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);
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 (GST_BUFFER_CAPS (src))
GST_BUFFER_CAPS (dest) = gst_caps_ref (GST_BUFFER_CAPS (src));
else
GST_BUFFER_CAPS (dest) = NULL;
gst_caps_replace (&GST_BUFFER_CAPS (dest), GST_BUFFER_CAPS (src));
}
}