ext/theora/theoraenc.c: Check return value of theora_encode_header(), or we might try to allocate a random number of ...

Original commit message from CVS:
* ext/theora/theoraenc.c: (theora_enc_chain):
Check return value of theora_encode_header(), or we might try to
allocate a random number of bytes. theora_encode_header() can fail
if libtheora has been compiled with encoding support disabled.
Fixes #398110.
This commit is contained in:
Tim-Philipp Müller 2007-01-29 18:14:25 +00:00
parent d49920f3a2
commit a37616d4df
2 changed files with 24 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2007-01-29 Tim-Philipp Müller <tim at centricular dot net>
* ext/theora/theoraenc.c: (theora_enc_chain):
Check return value of theora_encode_header(), or we might try to
allocate a random number of bytes. theora_encode_header() can fail
if libtheora has been compiled with encoding support disabled.
Fixes #398110.
2007-01-29 Wim Taymans <wim@fluendo.com>
* tests/check/gst/.cvsignore:

View file

@ -626,7 +626,9 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
libtheora handles the additional Ogg bitstream constraints */
/* first packet will get its own page automatically */
theora_encode_header (&enc->state, &op);
if (theora_encode_header (&enc->state, &op) != 0)
goto encoder_disabled;
ret = theora_buffer_from_packet (enc, &op, GST_CLOCK_TIME_NONE,
GST_CLOCK_TIME_NONE, &buf1);
if (ret != GST_FLOW_OK) {
@ -637,7 +639,9 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
theora_comment_clear (&enc->comment);
theora_comment_init (&enc->comment);
theora_encode_comment (&enc->comment, &op);
if (theora_encode_comment (&enc->comment, &op) != 0)
goto encoder_disabled;
ret = theora_buffer_from_packet (enc, &op, GST_CLOCK_TIME_NONE,
GST_CLOCK_TIME_NONE, &buf2);
/* Theora expects us to put this packet buffer into an ogg page,
@ -652,7 +656,9 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
goto header_buffer_alloc;
}
theora_encode_tables (&enc->state, &op);
if (theora_encode_tables (&enc->state, &op) != 0)
goto encoder_disabled;
ret = theora_buffer_from_packet (enc, &op, GST_CLOCK_TIME_NONE,
GST_CLOCK_TIME_NONE, &buf3);
if (ret != GST_FLOW_OK) {
@ -893,6 +899,13 @@ data_push:
gst_buffer_unref (buffer);
return ret;
}
encoder_disabled:
{
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL),
("libtheora has been compiled with the encoder disabled"));
gst_buffer_unref (buffer);
return GST_FLOW_ERROR;
}
}
static GstStateChangeReturn