Commit 7cbfe3ea authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

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.
parent fcf19950
......@@ -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:
......
......@@ -72,6 +72,8 @@ struct _GstJpegDec {
GstAdapter *adapter;
guint8 *cur_buf;
/* TRUE if each input buffer contains a whole jpeg image */
gboolean packetized;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment