jpegdec: Check return value of gst_buffer_map()

Without this check, the element will crash instead of returning an
error.
This commit is contained in:
Nicolas Dufresne 2020-01-27 17:16:02 -05:00 committed by GStreamer Merge Bot
parent eb0b676fae
commit 83e9d4f70d

View file

@ -1204,7 +1204,9 @@ gst_jpeg_dec_handle_frame (GstVideoDecoder * bdec, GstVideoCodecFrame * frame)
guint8 *data;
gsize nbytes;
gst_buffer_map (frame->input_buffer, &dec->current_frame_map, GST_MAP_READ);
if (!gst_buffer_map (frame->input_buffer, &dec->current_frame_map,
GST_MAP_READ))
goto map_failed;
data = dec->current_frame_map.data;
nbytes = dec->current_frame_map.size;
@ -1393,6 +1395,13 @@ need_more_data:
goto exit;
}
/* ERRORS */
map_failed:
{
GST_ELEMENT_ERROR (dec, RESOURCE, READ, (_("Failed to read memory")),
("gst_buffer_map() failed for READ access"));
ret = GST_FLOW_ERROR;
goto exit;
}
decode_error:
{
gchar err_msg[JMSG_LENGTH_MAX];