mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
camerabin2: Check before acessing preview location list
Only access the preview location if it exists, to avoid acessing a NULL variable. If the preview location list doesn't exist, it is likely because the source has posted a preview message after camerabin2 has been put to READY.
This commit is contained in:
parent
94d9327e2a
commit
61a7e6bf38
1 changed files with 21 additions and 12 deletions
|
@ -949,22 +949,31 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||||
}
|
}
|
||||||
} else if (gst_structure_has_name (structure, "preview-image")) {
|
} else if (gst_structure_has_name (structure, "preview-image")) {
|
||||||
GValue *value;
|
GValue *value;
|
||||||
gchar *location;
|
gchar *location = NULL;
|
||||||
|
|
||||||
g_mutex_lock (camerabin->preview_list_mutex);
|
g_mutex_lock (camerabin->preview_list_mutex);
|
||||||
location = camerabin->preview_location_list->data;
|
if (camerabin->preview_location_list) {
|
||||||
camerabin->preview_location_list =
|
location = camerabin->preview_location_list->data;
|
||||||
g_slist_delete_link (camerabin->preview_location_list,
|
camerabin->preview_location_list =
|
||||||
camerabin->preview_location_list);
|
g_slist_delete_link (camerabin->preview_location_list,
|
||||||
GST_DEBUG_OBJECT (camerabin, "Adding preview location to preview "
|
camerabin->preview_location_list);
|
||||||
"message '%s'", location);
|
GST_DEBUG_OBJECT (camerabin, "Adding preview location to preview "
|
||||||
|
"message '%s'", location);
|
||||||
|
} else {
|
||||||
|
GST_WARNING_OBJECT (camerabin, "Unexpected preview message received, "
|
||||||
|
"won't be able to put location field into the message. This can "
|
||||||
|
"happen if the source is posting previews while camerabin2 is "
|
||||||
|
"shutting down");
|
||||||
|
}
|
||||||
g_mutex_unlock (camerabin->preview_list_mutex);
|
g_mutex_unlock (camerabin->preview_list_mutex);
|
||||||
|
|
||||||
value = g_new0 (GValue, 1);
|
if (location) {
|
||||||
g_value_init (value, G_TYPE_STRING);
|
value = g_new0 (GValue, 1);
|
||||||
g_value_take_string (value, location);
|
g_value_init (value, G_TYPE_STRING);
|
||||||
gst_structure_take_value ((GstStructure *) structure, "location",
|
g_value_take_string (value, location);
|
||||||
value);
|
gst_structure_take_value ((GstStructure *) structure, "location",
|
||||||
|
value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue