celt: a bit more error checking on header parsing

https://bugzilla.gnome.org/show_bug.cgi?id=659087
This commit is contained in:
Vincent Penquerc'h 2011-09-14 20:22:42 +01:00 committed by Sebastian Dröge
parent d8684fffa1
commit fe0a2ec885
2 changed files with 16 additions and 2 deletions

View file

@ -560,8 +560,11 @@ celt_dec_chain_parse_header (GstCeltDec * dec, GstBuffer * buf)
gint error = CELT_OK; gint error = CELT_OK;
/* get the header */ /* get the header */
celt_header_from_packet ((const unsigned char *) GST_BUFFER_DATA (buf), error =
celt_header_from_packet ((const unsigned char *) GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf), &dec->header); GST_BUFFER_SIZE (buf), &dec->header);
if (error < 0)
goto invalid_header;
if (memcmp (dec->header.codec_id, "CELT ", 8) != 0) if (memcmp (dec->header.codec_id, "CELT ", 8) != 0)
goto invalid_header; goto invalid_header;

View file

@ -914,7 +914,11 @@ gst_celt_enc_chain (GstPad * pad, GstBuffer * buf)
unsigned char *data = g_malloc (header_size); unsigned char *data = g_malloc (header_size);
/* create header buffer */ /* create header buffer */
celt_header_to_packet (&enc->header, data, header_size); int error = celt_header_to_packet (&enc->header, data, header_size);
if (error < 0) {
g_free (data);
goto no_header;
}
buf1 = gst_celt_enc_buffer_from_data (enc, data, header_size, 0); buf1 = gst_celt_enc_buffer_from_data (enc, data, header_size, 0);
/* create comment buffer */ /* create comment buffer */
@ -1047,6 +1051,13 @@ not_setup:
goto done; goto done;
} }
no_header:
{
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL),
("Failed to encode header"));
ret = GST_FLOW_ERROR;
goto done;
}
} }