multipartdemux: avoid reading from inavlid memory

Read the timestamp of the incomming buffer before we push it in the adapter and
flush it out again as the buffer might be unreffed then and we read from invalid
memory.
Fixes #581444.
This commit is contained in:
Arnout Vandecappelle 2009-05-05 17:07:13 +02:00 committed by Wim Taymans
parent 3f2144c5ee
commit 439ca2c795

View file

@ -469,6 +469,7 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
{ {
GstMultipartDemux *multipart; GstMultipartDemux *multipart;
GstAdapter *adapter; GstAdapter *adapter;
GstClockTime timestamp;
gint size = 1; gint size = 1;
GstFlowReturn res; GstFlowReturn res;
@ -477,6 +478,8 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
res = GST_FLOW_OK; res = GST_FLOW_OK;
timestamp = GST_BUFFER_TIMESTAMP (buf);
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) { if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
gst_adapter_clear (adapter); gst_adapter_clear (adapter);
} }
@ -518,7 +521,7 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf)
gst_pad_push_event (srcpad->pad, event); gst_pad_push_event (srcpad->pad, event);
GST_BUFFER_TIMESTAMP (outbuf) = 0; GST_BUFFER_TIMESTAMP (outbuf) = 0;
} else { } else {
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
} }
GST_DEBUG_OBJECT (multipart, GST_DEBUG_OBJECT (multipart,
"pushing buffer with timestamp %" GST_TIME_FORMAT, "pushing buffer with timestamp %" GST_TIME_FORMAT,