ac3parse, dcaparse: check buffer size before trimming

and unref old buffer as soon as possible.
This commit is contained in:
Tim-Philipp Müller 2013-05-04 09:48:02 +01:00
parent 3462282b83
commit 68ac392e8f
2 changed files with 27 additions and 13 deletions

View file

@ -692,14 +692,21 @@ cleanup:
static GstFlowReturn
gst_ac3_parse_chain_priv (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstBuffer *newbuf;
GstFlowReturn ret;
GstAc3Parse *ac3parse = GST_AC3_PARSE (parent);
GstFlowReturn ret;
GstBuffer *newbuf;
gsize size;
size = gst_buffer_get_size (buffer);
if (size >= 2) {
newbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 2, size - 2);
gst_buffer_unref (buffer);
ret = ac3parse->baseparse_chainfunc (pad, parent, newbuf);
} else {
gst_buffer_unref (buffer);
ret = GST_FLOW_OK;
}
newbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL,
2, gst_buffer_get_size (buffer) - 2);
ret = ac3parse->baseparse_chainfunc (pad, parent, newbuf);
gst_buffer_unref (buffer);
return ret;
}

View file

@ -454,16 +454,23 @@ cleanup:
* */
static GstFlowReturn
gst_dca_parse_chain_priv (GstPad * pad, GstObject *parent, GstBuffer * buffer)
gst_dca_parse_chain_priv (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstBuffer *newbuf;
GstFlowReturn ret;
GstDcaParse *dcaparse = GST_DCA_PARSE (parent);
GstFlowReturn ret;
GstBuffer *newbuf;
gsize size;
size = gst_buffer_get_size (buffer);
if (size >= 2) {
newbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, 2, size - 2);
gst_buffer_unref (buffer);
ret = dcaparse->baseparse_chainfunc (pad, parent, newbuf);
} else {
gst_buffer_unref (buffer);
ret = GST_FLOW_OK;
}
newbuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL,
2, gst_buffer_get_size (buffer) - 2);
ret = dcaparse->baseparse_chainfunc (pad, parent, newbuf);
gst_buffer_unref (buffer);
return ret;
}