kms: fix crash if bo allocation failed when copying to dumb buffer

If bo allocation failed we destroy the buffer and return GST_FLOW_ERROR,
but the @buffer pointer was still pointing to the address of the
destroyed buffer. gst_kms_sink_copy_to_dumb_buffer() was then trying to
unref it when bailing out causing a crash.

Leave @buffer untouched if allocation failed to fix the crash.
Also remove the check on *buffer being not NULL as gst_buffer_new()
will abort if it failed.

https://bugzilla.gnome.org/show_bug.cgi?id=787442
This commit is contained in:
Guillaume Desmottes 2017-09-08 14:57:06 +02:00 committed by Nicolas Dufresne
parent fcf8b6bb90
commit 7e38fb5422

View file

@ -139,14 +139,11 @@ gst_kms_buffer_pool_alloc_buffer (GstBufferPool * pool, GstBuffer ** buffer,
priv = vpool->priv;
info = &priv->vinfo;
*buffer = gst_buffer_new ();
if (*buffer == NULL)
goto no_memory;
mem = gst_kms_allocator_bo_alloc (priv->allocator, info);
if (!mem) {
gst_buffer_unref (*buffer);
if (!mem)
goto no_memory;
}
*buffer = gst_buffer_new ();
gst_buffer_append_memory (*buffer, mem);
if (priv->add_videometa) {