discoverer: Only allow serializing OK discoverer infos to GVariants

They will be incomplete otherwise and we can't generate the full serialized
information, and instead will crash somewhere on the way.

https://bugzilla.gnome.org/show_bug.cgi?id=767859
This commit is contained in:
Sebastian Dröge 2016-06-21 10:24:15 +03:00
parent 2ac5bd293b
commit 26f63db498
2 changed files with 6 additions and 1 deletions

View file

@ -2200,11 +2200,14 @@ gst_discoverer_info_to_variant (GstDiscovererInfo * info,
/* FIXME: implement TOC support */ /* FIXME: implement TOC support */
GVariant *stream_variant; GVariant *stream_variant;
GVariant *variant; GVariant *variant;
GstDiscovererStreamInfo *sinfo = gst_discoverer_info_get_stream_info (info); GstDiscovererStreamInfo *sinfo;
GVariant *wrapper; GVariant *wrapper;
g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL); g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
g_return_val_if_fail (gst_discoverer_info_get_result (info) ==
GST_DISCOVERER_OK, NULL);
sinfo = gst_discoverer_info_get_stream_info (info);
stream_variant = gst_discoverer_info_to_variant_recurse (sinfo, flags); stream_variant = gst_discoverer_info_to_variant_recurse (sinfo, flags);
variant = variant =
g_variant_new ("(vv)", _serialize_info (info, flags), stream_variant); g_variant_new ("(vv)", _serialize_info (info, flags), stream_variant);

View file

@ -66,6 +66,8 @@ GST_START_TEST (test_disco_serializing)
info = gst_discoverer_discover_uri (dc, uri, &err); info = gst_discoverer_discover_uri (dc, uri, &err);
fail_unless (info); fail_unless (info);
fail_unless_equals_int (gst_discoverer_info_get_result (info),
GST_DISCOVERER_OK);
serialized = serialized =
gst_discoverer_info_to_variant (info, GST_DISCOVERER_SERIALIZE_ALL); gst_discoverer_info_to_variant (info, GST_DISCOVERER_SERIALIZE_ALL);