From 2af2d8359c835c1d9347c50b89b7c24658858d35 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Fri, 17 Aug 2018 16:09:30 +0200 Subject: Gstreamer: Fix crash when resolution or frame rates are requested When either resolution or frame rates have been requested when the camera is in unloaded state, caps might not have some values. Change-Id: Ie935c62d02e10f762957ecd9f89255ad0e8fbd0b Reviewed-by: Christian Stromme --- src/plugins/gstreamer/camerabin/camerabinsession.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/plugins/gstreamer/camerabin/camerabinsession.cpp') diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index e87e1b3f0..cfbc94bb4 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -1294,6 +1294,9 @@ QList< QPair > CameraBinSession::supportedFrameRates(const QSize &frame GstStructure *structure = gst_caps_get_structure(caps, i); gst_structure_set_name(structure, "video/x-raw"); const GValue *oldRate = gst_structure_get_value(structure, "framerate"); + if (!oldRate) + continue; + GValue rate; memset(&rate, 0, sizeof(rate)); g_value_init(&rate, G_VALUE_TYPE(oldRate)); @@ -1310,6 +1313,9 @@ QList< QPair > CameraBinSession::supportedFrameRates(const QSize &frame for (uint i=0; i CameraBinSession::supportedResolutions(QPair rate, gst_structure_set_name(structure, "video/x-raw"); const GValue *oldW = gst_structure_get_value(structure, "width"); const GValue *oldH = gst_structure_get_value(structure, "height"); + if (!oldW || !oldH) + continue; + GValue w; memset(&w, 0, sizeof(GValue)); GValue h; @@ -1425,6 +1434,8 @@ QList CameraBinSession::supportedResolutions(QPair rate, GstStructure *structure = gst_caps_get_structure(caps, i); const GValue *wValue = gst_structure_get_value(structure, "width"); const GValue *hValue = gst_structure_get_value(structure, "height"); + if (!wValue || !hValue) + continue; QPair wRange = valueRange(wValue, &isContinuous); QPair hRange = valueRange(hValue, &isContinuous); -- cgit v1.2.3