From 3d9d34bd60faeb940b36d992a47168fc895036ba Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Mon, 25 Jan 2010 14:16:22 +0200 Subject: [PATCH] v4l2src: don't deref NULL Error out when the pool gets shutdown. --- ext/jpeg/gstjpegenc.c | 6 ++++++ sys/v4l2/v4l2src_calls.c | 7 +++++++ tests/check/Makefile.am | 1 + 3 files changed, 14 insertions(+) diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index 73e674c9ea..12b03d28fd 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -517,6 +517,12 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf) jpegenc->jdest.next_output_byte = GST_BUFFER_DATA (jpegenc->output_buffer); jpegenc->jdest.free_in_buffer = GST_BUFFER_SIZE (jpegenc->output_buffer); + /* FIXME: shouldn't we also set + * - jpegenc->cinfo.max_{v,h}_samp_factor + * - jpegenc->cinfo.comp_info[0,1,2].{v,h}_samp_factor + * accordingly? + */ + /* prepare for raw input */ #if JPEG_LIB_VERSION >= 70 jpegenc->cinfo.do_fancy_downsampling = FALSE; diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c index 73de30250b..c07748a74a 100644 --- a/sys/v4l2/v4l2src_calls.c +++ b/sys/v4l2/v4l2src_calls.c @@ -105,6 +105,8 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf) v4l2object = v4l2src->v4l2object; pool = v4l2src->pool; + if (!pool) + goto no_buffer_pool; GST_DEBUG_OBJECT (v4l2src, "grab frame"); @@ -174,6 +176,11 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf) return GST_FLOW_OK; /* ERRORS */ +no_buffer_pool: + { + GST_DEBUG ("no buffer pool"); + return GST_FLOW_WRONG_STATE; + } select_error: { GST_ELEMENT_ERROR (pool->v4l2elem, RESOURCE, READ, (NULL), diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 1d1b703d9f..169bdf3440 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -82,6 +82,7 @@ endif check_PROGRAMS = \ generic/states \ + generic/capsrenegotiation \ $(check_annodex) \ elements/alphacolor \ elements/aspectratiocrop \