jpegdec: fix memory leak

Don't leak result of gst_adapter_take(). There are most likely
smarter things we can do, but let's keep things simple for the
release.

Fixes #623172.
This commit is contained in:
Tim-Philipp Müller 2010-06-29 23:18:23 +01:00
parent fcf1995020
commit 7cbfe3eae1
2 changed files with 11 additions and 1 deletions

View file

@ -215,7 +215,10 @@ gst_jpeg_dec_fill_input_buffer (j_decompress_ptr cinfo)
av = dec->rem_img_len;
dec->rem_img_len -= av;
cinfo->src->next_input_byte = gst_adapter_take (dec->adapter, av);
g_free (dec->cur_buf);
dec->cur_buf = gst_adapter_take (dec->adapter, av);
cinfo->src->next_input_byte = dec->cur_buf;
cinfo->src->bytes_in_buffer = av;
return TRUE;
@ -1538,6 +1541,8 @@ gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event)
jpeg_abort_decompress (&dec->cinfo);
gst_segment_init (&dec->segment, GST_FORMAT_UNDEFINED);
gst_adapter_clear (dec->adapter);
g_free (dec->cur_buf);
dec->cur_buf = NULL;
dec->parse_offset = 0;
dec->parse_entropy_len = 0;
dec->parse_resync = FALSE;
@ -1631,6 +1636,7 @@ gst_jpeg_dec_change_state (GstElement * element, GstStateChange transition)
dec->parse_offset = 0;
dec->parse_entropy_len = 0;
dec->parse_resync = FALSE;
dec->cur_buf = NULL;
gst_segment_init (&dec->segment, GST_FORMAT_UNDEFINED);
gst_jpeg_dec_reset_qos (dec);
default:
@ -1644,6 +1650,8 @@ gst_jpeg_dec_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_adapter_clear (dec->adapter);
g_free (dec->cur_buf);
dec->cur_buf = NULL;
gst_jpeg_dec_free_buffers (dec);
break;
default:

View file

@ -72,6 +72,8 @@ struct _GstJpegDec {
GstAdapter *adapter;
guint8 *cur_buf;
/* TRUE if each input buffer contains a whole jpeg image */
gboolean packetized;