From d32de37076ed82d2b604c05e6683cd3cf5bf9cbf Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 8 Aug 2005 15:08:14 +0000 Subject: [PATCH] gst/base/gstbasetransform.c: Fix a pretty good memleak. Original commit message from CVS: * gst/base/gstbasetransform.c: (gst_base_transform_buffer_alloc): Fix a pretty good memleak. --- ChangeLog | 5 +++++ gst/base/gstbasetransform.c | 13 +++++++++++-- libs/gst/base/gstbasetransform.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 754fe5ec15..e6d6cdaa4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-08 Ronald S. Bultje + + * gst/base/gstbasetransform.c: (gst_base_transform_buffer_alloc): + Fix a pretty good memleak. + 2005-08-08 Tim-Philipp Müller * gst/gstiterator.h: diff --git a/gst/base/gstbasetransform.c b/gst/base/gstbasetransform.c index d4b48f0aac..3dea71c1a0 100644 --- a/gst/base/gstbasetransform.c +++ b/gst/base/gstbasetransform.c @@ -535,6 +535,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size, goto unknown_size; } + if (*buf) { + gst_buffer_unref (*buf); + } *buf = gst_buffer_new_and_alloc (got_size); gst_buffer_set_caps (*buf, sinkcaps); GST_BUFFER_OFFSET (*buf) = offset; @@ -549,14 +552,20 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size, not_configured: { /* let the default allocator handle it */ - *buf = NULL; + if (*buf) { + gst_buffer_unref (*buf); + *buf = NULL; + } gst_object_unref (trans); return GST_FLOW_OK; } unknown_size: { /* let the default allocator handle it */ - *buf = NULL; + if (*buf) { + gst_buffer_unref (*buf); + *buf = NULL; + } gst_object_unref (trans); return GST_FLOW_OK; } diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index d4b48f0aac..3dea71c1a0 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -535,6 +535,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size, goto unknown_size; } + if (*buf) { + gst_buffer_unref (*buf); + } *buf = gst_buffer_new_and_alloc (got_size); gst_buffer_set_caps (*buf, sinkcaps); GST_BUFFER_OFFSET (*buf) = offset; @@ -549,14 +552,20 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size, not_configured: { /* let the default allocator handle it */ - *buf = NULL; + if (*buf) { + gst_buffer_unref (*buf); + *buf = NULL; + } gst_object_unref (trans); return GST_FLOW_OK; } unknown_size: { /* let the default allocator handle it */ - *buf = NULL; + if (*buf) { + gst_buffer_unref (*buf); + *buf = NULL; + } gst_object_unref (trans); return GST_FLOW_OK; }