Browse Source

Issue #792 - set errno=EINVAL if parsing the string in json_parse_int64 fails, to match the docs for json_object_get_int.

tags/json-c-0.17-20230812
Eric Haszlakiewicz 2 years ago
parent
commit
57bef5edc4
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      json_util.c

+ 6
- 1
json_util.c View File

@@ -247,7 +247,12 @@ int json_parse_int64(const char *buf, int64_t *retval)
val = strtoll(buf, &end, 10); val = strtoll(buf, &end, 10);
if (end != buf) if (end != buf)
*retval = val; *retval = val;
return ((val == 0 && errno != 0) || (end == buf)) ? 1 : 0;
if ((val == 0 && errno != 0) || (end == buf))
{
errno = EINVAL;
return 1;
}
return 0;
} }


int json_parse_uint64(const char *buf, uint64_t *retval) int json_parse_uint64(const char *buf, uint64_t *retval)


Loading…
Cancel
Save