From 480a7bcab8cf778d455bbd13ac43aed563525d1a Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 25 Jul 2018 19:27:01 -0400 Subject: [PATCH] v4l2bufferpool: Validate stride/offset when importing This will prevent situation where buffer size allow importing but rendering goes wrong due to a miss-match in expected stride and offset. https://bugzilla.gnome.org/show_bug.cgi?id=583890 --- sys/v4l2/gstv4l2bufferpool.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 8c10f996ff..6e4ac1c2de 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -742,10 +742,23 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool) GST_DEBUG_OBJECT (pool, "activating pool"); - if (pool->other_pool) + if (pool->other_pool) { + GstBuffer *buffer; + if (!gst_buffer_pool_set_active (pool->other_pool, TRUE)) goto other_pool_failed; + if (gst_buffer_pool_acquire_buffer (pool->other_pool, &buffer, NULL) != + GST_FLOW_OK) + goto other_pool_failed; + + if (!gst_v4l2_object_try_import (obj, buffer)) { + gst_buffer_unref (buffer); + goto cannot_import; + } + gst_buffer_unref (buffer); + } + config = gst_buffer_pool_get_config (bpool); if (!gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers)) @@ -912,6 +925,11 @@ queue_failed: GST_ERROR_OBJECT (pool, "failed to queue buffers into the capture queue"); return FALSE; } +cannot_import: + { + GST_ERROR_OBJECT (pool, "cannot import buffers from downstream pool"); + return FALSE; + } } static gboolean