From e807ac077d24bbefb48bb88dd16cff714f5e0195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 6 May 2014 09:48:58 +0100 Subject: [PATCH] pnmenc: fix flow return and buffer leak in not-negotiated case https://bugzilla.gnome.org/show_bug.cgi?id=729614 --- gst/pnm/gstpnmenc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gst/pnm/gstpnmenc.c b/gst/pnm/gstpnmenc.c index a47e6055e9..9c908a4514 100644 --- a/gst/pnm/gstpnmenc.c +++ b/gst/pnm/gstpnmenc.c @@ -112,10 +112,9 @@ gst_pnmenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) GstBuffer *out; - if ((s->info.width == 0) || (s->info.height == 0) || (s->info.fields == 0)) { - r = GST_FLOW_ERROR; - goto out; - } + if (s->info.width == 0 || s->info.height == 0 || s->info.fields == 0) + goto not_negotiated; + /* Assumption: One buffer, one image. That is, always first write header. */ header = g_strdup_printf ("P%i\n%i %i\n%i\n", s->info.type + 3 * (1 - s->info.encoding), s->info.width, s->info.height, @@ -182,6 +181,12 @@ gst_pnmenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) out: return r; + +not_negotiated: + { + gst_buffer_unref (buf); + return GST_FLOW_NOT_NEGOTIATED; + } } static gboolean