summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-utils.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-03-17 14:46:00 +0000
committerRichard Hughes <richard@hughsie.com>2017-03-17 14:46:00 +0000
commit1a327ebc8e45b07be0f193f768848f1d1be06433 (patch)
tree7334f41af333b7cdba2faad0d9a18e22f4d83186 /libappstream-glib/as-utils.c
parent48d22d2a6ee82d013252ff534af6e34913c710c9 (diff)
downloadappstream-glib-1a327ebc8e45b07be0f193f768848f1d1be06433.tar.gz
Parse small version numbers correctly
Based on a patch by Tim Chen <tim.chen119@canonical.com>
Diffstat (limited to 'libappstream-glib/as-utils.c')
-rw-r--r--libappstream-glib/as-utils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 854eec1..e15529f 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -1574,6 +1574,7 @@ as_utils_version_from_uint16 (guint16 val, AsVersionParseFlag flags)
gchar *
as_utils_version_parse (const gchar *version)
{
+ const gchar *version_noprefix = version;
gchar *endptr = NULL;
guint64 tmp;
guint base;
@@ -1590,7 +1591,7 @@ as_utils_version_parse (const gchar *version)
/* convert 0x prefixed strings to dotted decimal */
if (g_str_has_prefix (version, "0x")) {
- version += 2;
+ version_noprefix += 2;
base = 16;
} else {
/* for non-numeric content, just return the string */
@@ -1602,10 +1603,10 @@ as_utils_version_parse (const gchar *version)
}
/* convert */
- tmp = g_ascii_strtoull (version, &endptr, base);
+ tmp = g_ascii_strtoull (version_noprefix, &endptr, base);
if (endptr != NULL && endptr[0] != '\0')
return g_strdup (version);
- if (tmp == 0 || tmp < 0xff)
+ if (tmp == 0)
return g_strdup (version);
return as_utils_version_from_uint32 ((guint32) tmp, AS_VERSION_PARSE_FLAG_USE_TRIPLET);
}