From 1a2bd6c617dff728a93801d98aeb81d1c8bd5c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 19 Feb 2009 20:14:10 +0000 Subject: [PATCH] jpegenc: error out instead of crashing if no caps have been set Don't crash if we receive a buffer without caps. Fixes #572413. --- ext/jpeg/gstjpegenc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index df4b416f59..5edb11f1a9 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -427,6 +427,9 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf) jpegenc = GST_JPEGENC (GST_OBJECT_PARENT (pad)); + if (G_UNLIKELY (jpegenc->width <= 0 || jpegenc->height <= 0)) + goto not_negotiated; + data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); @@ -495,6 +498,14 @@ done: gst_buffer_unref (buf); return ret; + +/* ERRORS */ +not_negotiated: + { + GST_WARNING_OBJECT (jpegenc, "no input format set (no caps on buffer)"); + ret = GST_FLOW_NOT_NEGOTIATED; + goto done; + } } static void @@ -572,6 +583,8 @@ gst_jpegenc_change_state (GstElement * element, GstStateChange transition) filter->line[0] = NULL; filter->line[1] = NULL; filter->line[2] = NULL; + filter->width = -1; + filter->height = -1; break; default: break;