diff options
author | Richard Hughes <richard@hughsie.com> | 2015-12-16 11:48:39 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-12-16 11:48:39 +0000 |
commit | 2f037ff1d9d8787f92b4fb7598bc016f19ba7046 (patch) | |
tree | 5eeb6af20ff8b6632fb3ada201585c864a98ec6a /libappstream-glib/as-app-validate.c | |
parent | 3c82370584dd9d99a4152aa6732a32401da6a13e (diff) | |
download | appstream-glib-2f037ff1d9d8787f92b4fb7598bc016f19ba7046.tar.gz |
Fix a crash when tokenizing a NULL string
Diffstat (limited to 'libappstream-glib/as-app-validate.c')
-rw-r--r-- | libappstream-glib/as-app-validate.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c index 1bd2638..cb31924 100644 --- a/libappstream-glib/as-app-validate.c +++ b/libappstream-glib/as-app-validate.c @@ -958,6 +958,14 @@ as_app_validate_license (const gchar *license_text, GError **error) g_auto(GStrv) licenses = NULL; licenses = as_utils_spdx_license_tokenize (license_text); + if (licenses == NULL) { + g_set_error (error, + AS_APP_ERROR, + AS_APP_ERROR_FAILED, + "SPDX license text '%s' could not be parsed", + license_text); + return FALSE; + } for (i = 0; licenses[i] != NULL; i++) { if (g_strcmp0 (licenses[i], "&") == 0 || g_strcmp0 (licenses[i], "|") == 0 || @@ -986,6 +994,8 @@ as_app_validate_is_content_license (const gchar *license) guint i; g_auto(GStrv) tokens = NULL; tokens = as_utils_spdx_license_tokenize (license); + if (tokens == NULL) + return FALSE; for (i = 0; tokens[i] != NULL; i++) { if (g_strcmp0 (tokens[i], "@CC0-1.0") == 0) continue; |