Browse Source

Issue #173: since some sscanf implementations return 0 for non-zero inputs, directly check for "0" in the input.

tags/json-c-0.13-20171207
Eric Haszlakiewicz 8 years ago
parent
commit
b2afca4560
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      json_util.c

+ 3
- 1
json_util.c View 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);


Loading…
Cancel
Save