Skip to content

jifmux: Make copies of parsed image buffer parts

I've encountered a bug with jifmux when working on a webcam JPEG stream directly. It can be easily reproduced as: gst-launch-1.0 v4l2src device=/dev/cameraX ! image/jpeg ! jifmux ! fakesink

This causes a segmentation fault whereas neither working on the output of jpegenc or filesrc does. I've spend some time debugging today and it seemingly turns out that the byte readers do not allocate any memory and just pass pointers to the section of the original buffer. In my case, the buffers seem to get freed behind the scenes so that when we get to gst_jif_mux_mangle_markers/gst_jif_mux_recombine_image functions, the memory is no longer accessible and the process crashes. The fact that gst_jif_mux_marker_free frees the data intentionally seems to suggest that either a copy was meant to be made or the byte readers used to work differently. On the other hand self->scan_data isn't ever freed.

I'm not a deep Glib/GStreamer expert, but I managed to fix it to the best of my understanding of what's going on and it does resolve the issue.

Merge request reports

Loading