pylonsrc: check strings before reading

This commit is contained in:
mrstecklo 2020-12-26 14:25:38 +03:00 committed by joshdoe
parent 6b286964ca
commit 11b85fcc3a

View File

@ -1267,6 +1267,17 @@ feature_available(const GstPylonSrc* src, const char* feature)
} }
} }
static inline _Bool
feature_readable(const GstPylonSrc* src, const char* feature)
{
if(PylonDeviceFeatureIsReadable(src->deviceHandle, feature)) {
return TRUE;
} else {
GST_WARNING_OBJECT (src, "Feature is not readable: %s", feature);
return FALSE;
}
}
static gboolean static gboolean
gst_pylonsrc_set_trigger (GstPylonSrc * src) gst_pylonsrc_set_trigger (GstPylonSrc * src)
{ {
@ -2613,6 +2624,7 @@ error:
static gchar* static gchar*
read_string_feature(GstPylonSrc* src, const char* feature) read_string_feature(GstPylonSrc* src, const char* feature)
{ {
if(feature_readable(src, feature)) {
gchar* result = NULL; gchar* result = NULL;
size_t bufLen = 0; size_t bufLen = 0;
@ -2630,6 +2642,7 @@ read_string_feature(GstPylonSrc* src, const char* feature)
error: error:
g_free(result); g_free(result);
}
return NULL; return NULL;
} }