Crash in jpegdec using Panacast camera
I recently encountered a random but frequent SIGSEGV when using the Panacast camera (https://www.panacast.com/). After some debugging it turns out that the first few JPEG frames are sometimes invalid, containing no data at all. The following diff shows how I "fixed" the problem:
--- a/ext/jpeg/gstjpegdec.c
+++ b/ext/jpeg/gstjpegdec.c
@@ -1202,6 +1202,8 @@ gst_jpeg_dec_handle_frame (GstVideoDecoder * bdec, GstVideoCodecFrame * frame)
data = dec->current_frame_map.data;
nbytes = dec->current_frame_map.size;
+ if (nbytes == 0)
+ goto need_more_data;
has_eoi = ((data[nbytes - 2] != 0xff) || (data[nbytes - 1] != 0xd9));
/* some cameras fail to send an end-of-image marker (EOI),
I'm not making a merge request because I'm pretty sure this is the wrong way to handle this, so I'm open to suggestions.