diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2012-11-05 16:31:16 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2012-11-05 16:31:16 +0000 |
commit | c237f04233bc53022df17909cb185e3ea0c67c37 (patch) | |
tree | 74f1960c208f633888ae9e7faf3f49c626ff42f7 | |
parent | af632d3bfd548e705a902dcd79b9a906679ef482 (diff) |
jpegenc: error out gracefully if input buffer is too small
https://bugzilla.gnome.org/show_bug.cgi?id=687643
-rw-r--r-- | ext/jpeg/gstjpegenc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index cf3b2b68e..627d777e3 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -432,6 +432,9 @@ gst_jpegenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame) GST_LOG_OBJECT (jpegenc, "got buffer of %lu bytes", size); + if (size < GST_VIDEO_INFO_SIZE (&jpegenc->input_state->info)) + goto input_too_small; + jpegenc->current_frame = frame; jpegenc->output_buffer = frame->output_buffer = gst_buffer_new_and_alloc (jpegenc->bufsize); @@ -499,6 +502,18 @@ gst_jpegenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame) GST_LOG_OBJECT (jpegenc, "compressing done"); return GST_FLOW_OK; + +/* ERRORS */ +input_too_small: + { + GST_ELEMENT_ERROR (jpegenc, STREAM, ENCODE, (NULL), + ("Input video buffer too small, expected at least %lu bytes, but got " + "only %lu bytes. This is either a bug in an upstream element or " + "you need to use the videoparse element to read raw video data in the " + "right chunking.", + GST_VIDEO_INFO_SIZE (&jpegenc->input_state->info), size)); + return GST_FLOW_ERROR; + } } static void |