jpegdec: don't leak output buffers on decoding errors

The setjmp handles libjpeg error. Free the outputbffer if we don't need it.
This commit is contained in:
Stefan Kost 2009-09-29 17:51:04 +03:00
parent 477cb58640
commit b1feeee166

View file

@ -850,7 +850,7 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
{ {
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GstJpegDec *dec; GstJpegDec *dec;
GstBuffer *outbuf; GstBuffer *outbuf = NULL;
guchar *data, *outdata; guchar *data, *outdata;
guchar *base[3], *last[3]; guchar *base[3], *last[3];
guint img_len, outsize; guint img_len, outsize;
@ -1143,6 +1143,10 @@ exit:
need_more_data: need_more_data:
{ {
GST_LOG_OBJECT (dec, "we need more data"); GST_LOG_OBJECT (dec, "we need more data");
if (outbuf) {
gst_buffer_unref (outbuf);
outbuf = NULL;
}
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
goto exit; goto exit;
} }
@ -1160,6 +1164,10 @@ decode_error:
GST_ELEMENT_ERROR (dec, STREAM, DECODE, GST_ELEMENT_ERROR (dec, STREAM, DECODE,
(_("Failed to decode JPEG image")), (_("Failed to decode JPEG image")),
("Error #%u: %s", code, dec->jerr.pub.jpeg_message_table[code])); ("Error #%u: %s", code, dec->jerr.pub.jpeg_message_table[code]));
if (outbuf) {
gst_buffer_unref (outbuf);
outbuf = NULL;
}
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
goto done; goto done;
} }