From 2e1b6ec9964ca7d1427d93a571d2f99e464a67b3 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 15 Mar 2018 09:57:24 +0900 Subject: [PATCH] reset errno before calling strtoimax. --- parson.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parson.c b/parson.c index 513946f..fafaf9a 100644 --- a/parson.c +++ b/parson.c @@ -784,7 +784,9 @@ static JSON_Value * parse_number_value(const char **string) { char *end; double number = 0; #ifdef JSON_FIXED_NUMBER - intmax_t fixed = strtoimax(*string, &end, 10); + intmax_t fixed; + errno = 0; + fixed = strtoimax(*string, &end, 10); if (errno == 0 && INT64_MIN <= fixed && fixed <= INT64_MAX) { *string = end; return json_value_init_fixed(fixed);