From 44e20bd2e921464185fd12a1ea43b691779a127b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 15 Apr 2021 09:01:01 +0100 Subject: Do not show a critical warning on Fixes https://github.com/hughsie/appstream-glib/issues/396 --- libappstream-glib/as-self-test.c | 21 +++++++++++++++++++++ libappstream-glib/as-suggest.c | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 78af947..29fc20a 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -4189,6 +4189,26 @@ as_test_store_versions_func (void) g_object_unref (store); } +static void +as_test_store_invalid_func (void) +{ + gboolean ret; + g_autoptr(AsStore) store; + g_autoptr(GError) error = NULL; + + /* load a file to the store */ + store = as_store_new (); + ret = as_store_from_xml (store, + "" + "" + "test.desktop" + "" + "" + "", NULL, &error); + g_assert_no_error (error); + g_assert_true (ret); +} + static void as_test_store_addons_func (void) { @@ -5851,6 +5871,7 @@ main (int argc, char **argv) g_test_add_func ("/AppStream/store{merges}", as_test_store_merges_func); g_test_add_func ("/AppStream/store{merges-local}", as_test_store_merges_local_func); g_test_add_func ("/AppStream/store{addons}", as_test_store_addons_func); + g_test_add_func ("/AppStream/store{invalid}", as_test_store_invalid_func); g_test_add_func ("/AppStream/store{versions}", as_test_store_versions_func); g_test_add_func ("/AppStream/store{origin}", as_test_store_origin_func); g_test_add_func ("/AppStream/store{yaml}", as_test_store_yaml_func); diff --git a/libappstream-glib/as-suggest.c b/libappstream-glib/as-suggest.c index d9f90ac..707f3a0 100644 --- a/libappstream-glib/as-suggest.c +++ b/libappstream-glib/as-suggest.c @@ -168,6 +168,7 @@ as_suggest_add_id (AsSuggest *suggest, const gchar *id) { AsSuggestPrivate *priv = GET_PRIVATE (suggest); g_return_if_fail (AS_IS_SUGGEST (suggest)); + g_return_if_fail (id != NULL); g_ptr_array_add (priv->ids, as_ref_string_new (id)); } @@ -233,7 +234,8 @@ as_suggest_node_parse (AsSuggest *suggest, GNode *node, if (tmp != NULL) as_suggest_set_kind (suggest, as_suggest_kind_from_string (tmp)); for (c = node->children; c != NULL; c = c->next) { - if (as_node_get_tag (c) == AS_TAG_ID) + if (as_node_get_tag (c) == AS_TAG_ID && + as_node_get_data (c) != NULL) as_suggest_add_id (suggest, as_node_get_data (c)); } return TRUE; -- cgit v1.2.1