From 7d6fd42726a9e1f2705ee21bbc756cdd16460750 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 6 Aug 2015 18:04:41 -0400 Subject: bayer2rgb: Protect against failing map --- gst/bayer/gstbayer2rgb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'gst/bayer') diff --git a/gst/bayer/gstbayer2rgb.c b/gst/bayer/gstbayer2rgb.c index 036ac2a86..edeb6bf26 100644 --- a/gst/bayer/gstbayer2rgb.c +++ b/gst/bayer/gstbayer2rgb.c @@ -462,14 +462,25 @@ gst_bayer2rgb_transform (GstBaseTransform * base, GstBuffer * inbuf, GstVideoFrame frame; GST_DEBUG ("transforming buffer"); - gst_buffer_map (inbuf, &map, GST_MAP_READ); - gst_video_frame_map (&frame, &filter->info, outbuf, GST_MAP_WRITE); + + if (!gst_buffer_map (inbuf, &map, GST_MAP_READ)) + goto map_failed; + + if (!gst_video_frame_map (&frame, &filter->info, outbuf, GST_MAP_WRITE)) { + gst_buffer_unmap (inbuf, &map); + goto map_failed; + } output = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0); gst_bayer2rgb_process (filter, output, filter->width * 4, map.data, filter->width); + gst_video_frame_unmap (&frame); gst_buffer_unmap (inbuf, &map); return GST_FLOW_OK; + +map_failed: + GST_WARNING_OBJECT (base, "Could not map buffer, skipping"); + return GST_FLOW_OK; } -- cgit v1.2.3