Commit 68ac392e authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

ac3parse, dcaparse: check buffer size before trimming

and unref old buffer as soon as possible.
parent 3462282b
......@@ -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;
}
......
......@@ -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;
}
......
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