summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2012-11-05 16:31:16 +0000
committerTim-Philipp Müller <tim@centricular.net>2012-11-05 16:31:16 +0000
commitc237f04233bc53022df17909cb185e3ea0c67c37 (patch)
tree74f1960c208f633888ae9e7faf3f49c626ff42f7
parentaf632d3bfd548e705a902dcd79b9a906679ef482 (diff)
downloadgstreamer-plugins-good-c237f04233bc53022df17909cb185e3ea0c67c37.tar.gz
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.c15
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