basetransform: Check if meta transform_func is NULL before using it

An untested pointer segfaulted in webkit while playing video
on imx6 sabrelite. It turned out that the imx plugin didn't
implement the meta transform function.

The following GST_DEBUG trace was visible:
gstbasetransform.c:1779:foreach_metadata:<conv2> copy metadata
                                                GstImxVpuBufferMetaAPI

Thread 26 vqueue:src received signal SIGSEGV, Segmentation fault.

(gdb) bt
 0x00000000 in ?? ()
 0x73f8d7d8 in foreach_metadata (inbuf=0xc9b020, meta=0x474b2490,
                  user_data=<optimized out>) at gstbasetransform.c:1781
 0x73eb3ea8 in gst_buffer_foreach_meta (buffer=buffer@entry=0xc9b020,
                  func=0x73f8d705 <foreach_metadata>,
                  user_data=user_data@entry=0x474b24d4)
                  at gstbuffer.c:2234

https://bugzilla.gnome.org/show_bug.cgi?id=782050
This commit is contained in:
Frédéric Dalleau 2017-05-02 10:32:54 +02:00 committed by Sebastian Dröge
parent d108ed2251
commit ca7fa6a661

View file

@ -1712,10 +1712,15 @@ foreach_metadata (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
* function and when it returns %TRUE */
if (do_copy) {
GstMetaTransformCopy copy_data = { FALSE, 0, -1 };
GST_DEBUG_OBJECT (trans, "copy metadata %s", g_type_name (info->api));
/* simply copy then */
info->transform_func (outbuf, *meta, inbuf,
_gst_meta_transform_copy, &copy_data);
if (info->transform_func) {
GST_DEBUG_OBJECT (trans, "copy metadata %s", g_type_name (info->api));
info->transform_func (outbuf, *meta, inbuf,
_gst_meta_transform_copy, &copy_data);
} else {
GST_DEBUG_OBJECT (trans, "couldn't copy metadata %s",
g_type_name (info->api));
}
}
return TRUE;
}