From 796b0fec7d9005d70c5f5b1b970780c28f83dca8 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Wed, 6 Mar 2019 17:14:59 +0100 Subject: [PATCH] videoio: gst: Fix gst assertion on null msg According to the gstreamer docs [1], the GstMessage pointer returned by gst_bus_pop() is nullable, meaning NULL is a valid return value. Previously, gst_is_missing_plugin_message would throw an assert when its message object parameter would fail the GST_IS_MESSAGE macro check, crashing the entire process (unless running in a try-catch block of course). Instead of relying on valid messages, check if the message object itself is valid before passing it to other gstreamer functions. [1] https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBus.html#gst-bus-pop Signed-off-by: Christopher N. Hesse --- modules/videoio/src/cap_gstreamer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/videoio/src/cap_gstreamer.cpp b/modules/videoio/src/cap_gstreamer.cpp index 23d39d247a..95ff159cc3 100644 --- a/modules/videoio/src/cap_gstreamer.cpp +++ b/modules/videoio/src/cap_gstreamer.cpp @@ -1811,6 +1811,10 @@ void handleMessage(GstElement * pipeline) while(gst_bus_have_pending(bus)) { msg = gst_bus_pop(bus); + if (!msg || !GST_IS_MESSAGE(msg)) + { + continue; + } //printf("\t\tGot %s message\n", GST_MESSAGE_TYPE_NAME(msg));