]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #173: since some sscanf implementations return 0 for non-zero inputs, directly...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Tue, 5 Sep 2017 05:53:13 +0000 (01:53 -0400)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Tue, 5 Sep 2017 05:53:13 +0000 (01:53 -0400)
json_util.c

index 2121150a02edb3f400ef3c7bedc1494b6e3f4513..4624668891bdcde908136168d3a28ea1d9b3465a 100644 (file)
@@ -265,7 +265,9 @@ int json_parse_int64(const char *buf, int64_t *retval)
                // Skip leading zeros, but keep at least one digit
                while (buf_sig_digits[0] == '0' && buf_sig_digits[1] != '\0')
                        buf_sig_digits++;
-               if (num64 == 0) // assume all sscanf impl's will parse -0 to 0
+               // Can't check num64==0 because some sscanf impl's parse
+               //  non-zero values to 0.  (e.g. Illumos with UINT64_MAX)
+               if (buf_sig_digits[0] == '0' && buf_sig_digits[1] == '\0')
                        orig_has_neg = 0; // "-0" is the same as just plain "0"
 
                snprintf(buf_cmp_start, sizeof(buf_cmp), "%" PRId64, num64);