From ca7fa6a661d8a394ef1ae6f28a09a0e35fb0ab3f Mon Sep 17 00:00:00 2001 From: Frédéric Dalleau Date: Tue, 2 May 2017 10:32:54 +0200 Subject: 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: 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=) at gstbasetransform.c:1781 0x73eb3ea8 in gst_buffer_foreach_meta (buffer=buffer@entry=0xc9b020, func=0x73f8d705 , user_data=user_data@entry=0x474b24d4) at gstbuffer.c:2234 https://bugzilla.gnome.org/show_bug.cgi?id=782050 --- libs/gst/base/gstbasetransform.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 3157fb725..f90d75193 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -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, ©_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, ©_data); + } else { + GST_DEBUG_OBJECT (trans, "couldn't copy metadata %s", + g_type_name (info->api)); + } } return TRUE; } -- cgit v1.2.3