v4l2codecs: Fix segfaults when VIDIOC_REQBUFS doesn't return enough buffers
Running this pipeline:
gst-launch-1.0 -v filesrc location=test.mkv ! matroskademux ! v4l2slh264dec ! x264enc ! fakesink
The default settings for x264enc
require more than 32 buffers which will cause VIDIOC_REQBUFS
to return too few buffers.
This leads to two segfaults:
- First we segfault in the allocator finalize function when trying to use the
decoder
variable when it'sNULL
. - Then (after the allocator creation has failed) we segfault in the pool creation function trying to use a
NULL
allocator.