diff options
author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2018-01-23 14:32:25 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2018-01-23 14:22:11 +0000 |
commit | 628474b5b3a82e779447e296c3e019fe913800ff (patch) | |
tree | 766d529323a88a230367c49939de2628c149c192 | |
parent | ece8c02eb0a4ddf80335624ef34bb363eca65622 (diff) | |
download | appstream-glib-628474b5b3a82e779447e296c3e019fe913800ff.tar.gz |
as-app-desktop: don't deference invalid lists
Malformed .desktop files might causes crashes when
returned lists are NULL.
-rw-r--r-- | libappstream-glib/as-app-desktop.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libappstream-glib/as-app-desktop.c b/libappstream-glib/as-app-desktop.c index 1f12683..fadf4ab 100644 --- a/libappstream-glib/as-app-desktop.c +++ b/libappstream-glib/as-app-desktop.c @@ -236,7 +236,7 @@ as_app_parse_file_key (AsApp *app, G_KEY_FILE_DESKTOP_GROUP, key, NULL, NULL); - for (i = 0; list[i] != NULL; i++) { + for (i = 0; list != NULL && list[i] != NULL; i++) { const gchar *category_blacklist[] = { "X-GNOME-Settings-Panel", "X-Unity-Settings-Panel", @@ -271,7 +271,7 @@ as_app_parse_file_key (AsApp *app, G_KEY_FILE_DESKTOP_GROUP, key, NULL, NULL); - for (i = 0; list[i] != NULL; i++) { + for (i = 0; list != NULL && list[i] != NULL; i++) { g_auto(GStrv) kw_split = NULL; kw_split = g_strsplit (list[i], ",", -1); for (j = 0; kw_split[j] != NULL; j++) { @@ -291,7 +291,7 @@ as_app_parse_file_key (AsApp *app, key, locale, NULL, NULL); - for (i = 0; list[i] != NULL; i++) { + for (i = 0; list != NULL && list[i] != NULL; i++) { g_auto(GStrv) kw_split = NULL; kw_split = g_strsplit (list[i], ",", -1); for (j = 0; kw_split[j] != NULL; j++) { @@ -306,7 +306,7 @@ as_app_parse_file_key (AsApp *app, G_KEY_FILE_DESKTOP_GROUP, key, NULL, NULL); - for (i = 0; list[i] != NULL; i++) + for (i = 0; list != NULL && list[i] != NULL; i++) as_app_add_mimetype (app, list[i]); } else if (g_strcmp0 (key, "X-AppInstall-Package") == 0) { |