summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2018-06-04 11:22:07 +0100
committerRichard Hughes <richard@hughsie.com>2018-06-04 11:22:09 +0100
commit9047213878925da65e19dd57497d5381f24adf99 (patch)
treef92f3fb70aa920d668ede9b2dbec4b0590ebf4d6
parentb1cdc4d04875c3a93161266fc4b9737c157d152a (diff)
downloadappstream-glib-9047213878925da65e19dd57497d5381f24adf99.tar.gz
trivial: Fix a potential crash in the newly added version comparison code
Spotted by Coverity, many thanks.
-rw-r--r--libappstream-glib/as-utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 4a40308..29f1637 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -1369,6 +1369,16 @@ static gint
as_utils_vercmp_chunk (const gchar *str1, const gchar *str2)
{
guint i;
+
+ /* trivial */
+ if (g_strcmp0 (str1, str2) == 0)
+ return 0;
+ if (str1 == NULL)
+ return 1;
+ if (str2 == NULL)
+ return -1;
+
+ /* check each char of the chunk */
for (i = 0; str1[i] != '\0' && str2[i] != '\0'; i++) {
gint rc = as_utils_vercmp_char (str1[i], str2[i]);
if (rc != 0)