From b1feeee166b316689f1a3020d7ef37146fbf2ef1 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Tue, 29 Sep 2009 17:51:04 +0300 Subject: [PATCH] jpegdec: don't leak output buffers on decoding errors The setjmp handles libjpeg error. Free the outputbffer if we don't need it. --- ext/jpeg/gstjpegdec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index bb3961d..1d2d4dd 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -850,7 +850,7 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; GstJpegDec *dec; - GstBuffer *outbuf; + GstBuffer *outbuf = NULL; guchar *data, *outdata; guchar *base[3], *last[3]; guint img_len, outsize; @@ -1143,6 +1143,10 @@ exit: need_more_data: { GST_LOG_OBJECT (dec, "we need more data"); + if (outbuf) { + gst_buffer_unref (outbuf); + outbuf = NULL; + } ret = GST_FLOW_OK; goto exit; } @@ -1160,6 +1164,10 @@ decode_error: GST_ELEMENT_ERROR (dec, STREAM, DECODE, (_("Failed to decode JPEG image")), ("Error #%u: %s", code, dec->jerr.pub.jpeg_message_table[code])); + if (outbuf) { + gst_buffer_unref (outbuf); + outbuf = NULL; + } ret = GST_FLOW_ERROR; goto done; } -- 2.7.4