mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
v4l2codecs: Handle allocator creation failure
If `VIDIOC_REQBUFS` doesn't return enough buffers the allocator creation function can fail and return `NULL`. Handle this by generating an error and returning instead of segfaulting. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1220>
This commit is contained in:
parent
3846b0563a
commit
8b932c105f
2 changed files with 26 additions and 0 deletions
|
@ -422,8 +422,21 @@ gst_v4l2_codec_h264_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
|
||||
self->sink_allocator = gst_v4l2_codec_allocator_new (self->decoder,
|
||||
GST_PAD_SINK, num_bitstream);
|
||||
if (!self->sink_allocator) {
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, NO_SPACE_LEFT,
|
||||
("Not enough memory to allocate sink buffers."), (NULL));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->src_allocator = gst_v4l2_codec_allocator_new (self->decoder,
|
||||
GST_PAD_SRC, self->min_pool_size + min + 4);
|
||||
if (!self->src_allocator) {
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, NO_SPACE_LEFT,
|
||||
("Not enough memory to allocate source buffers."), (NULL));
|
||||
g_clear_object (&self->sink_allocator);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->src_pool = gst_v4l2_codec_pool_new (self->src_allocator, &self->vinfo);
|
||||
|
||||
/* Our buffer pool is internal, we will let the base class create a video
|
||||
|
|
|
@ -289,8 +289,21 @@ gst_v4l2_codec_vp8_dec_decide_allocation (GstVideoDecoder * decoder,
|
|||
|
||||
self->sink_allocator = gst_v4l2_codec_allocator_new (self->decoder,
|
||||
GST_PAD_SINK, num_bitstream);
|
||||
if (!self->sink_allocator) {
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, NO_SPACE_LEFT,
|
||||
("Not enough memory to allocate sink buffers."), (NULL));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->src_allocator = gst_v4l2_codec_allocator_new (self->decoder,
|
||||
GST_PAD_SRC, self->min_pool_size + min + 4);
|
||||
if (!self->src_allocator) {
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, NO_SPACE_LEFT,
|
||||
("Not enough memory to allocate source buffers."), (NULL));
|
||||
g_clear_object (&self->sink_allocator);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self->src_pool = gst_v4l2_codec_pool_new (self->src_allocator, &self->vinfo);
|
||||
|
||||
/* Our buffer pool is internal, we will let the base class create a video
|
||||
|
|
Loading…
Reference in a new issue