From de5e1e334e8a12096cfcf18d5855eeb74f06f5ba Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 25 Jul 2023 12:19:22 -0400 Subject: [PATCH] v4l2: bufferpool: Fix buffer resize asserstion When we fill a bitstream buffer the buffer might be too small to hold the entire frame. Only resize to the filled size, preventing the following assertion to happen. gst_buffer_resize_range: assertion 'bufmax >= bufoffs + offset + size' failed Part-of: --- subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c index e12ec10156..58d06cb163 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c @@ -164,16 +164,18 @@ gst_v4l2_buffer_pool_copy_buffer (GstV4l2BufferPool * pool, GstBuffer * dest, gst_video_frame_unmap (&dest_frame); } else { GstMapInfo map; + gsize filled_size; GST_DEBUG_OBJECT (pool, "copy raw bytes"); if (!gst_buffer_map (src, &map, GST_MAP_READ)) goto invalid_buffer; - gst_buffer_fill (dest, 0, map.data, gst_buffer_get_size (src)); + filled_size = + gst_buffer_fill (dest, 0, map.data, gst_buffer_get_size (src)); gst_buffer_unmap (src, &map); - gst_buffer_resize (dest, 0, gst_buffer_get_size (src)); + gst_buffer_resize (dest, 0, filled_size); } gst_buffer_copy_into (dest, src,