From 57bef5edc48ad30e794f64fdfc855e955046d25d Mon Sep 17 00:00:00 2001 From: Eric Haszlakiewicz Date: Wed, 26 Oct 2022 02:19:38 +0000 Subject: [PATCH] Issue #792 - set errno=EINVAL if parsing the string in json_parse_int64 fails, to match the docs for json_object_get_int. --- json_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/json_util.c b/json_util.c index 83d9c68319..1a2dfcdd85 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)