diff options
author | Eric Haszlakiewicz <erh+git@nimenees.com> | 2022-10-26 02:19:38 +0000 |
---|---|---|
committer | Eric Haszlakiewicz <erh+git@nimenees.com> | 2022-10-26 02:19:38 +0000 |
commit | 57bef5edc48ad30e794f64fdfc855e955046d25d (patch) | |
tree | 93f665983d3ce0181816dc9410e63e536db2d4eb | |
parent | 777dd06be83ef7fac71c2218b565557cd068a714 (diff) | |
download | json-c-57bef5edc48ad30e794f64fdfc855e955046d25d.tar.gz |
Issue #792 - set errno=EINVAL if parsing the string in json_parse_int64 fails, to match the docs for json_object_get_int.
-rw-r--r-- | json_util.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/json_util.c b/json_util.c index 83d9c68..1a2dfcd 100644 --- a/json_util.c +++ b/json_util.c @@ -247,7 +247,12 @@ int json_parse_int64(const char *buf, int64_t *retval) val = strtoll(buf, &end, 10); if (end != buf) *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) |