From 2b7adfe30633b72d9e533ba75c438adbbe9d5a5d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 18 Sep 2020 09:25:21 +0900 Subject: [PATCH] is_decimal: Fix an integer underflow. It seems harmless though. Found by UBSAN parson.c:270:18: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') --- parson.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parson.c b/parson.c index 20cb43f..f2e0ae7 100644 --- a/parson.c +++ b/parson.c @@ -274,7 +274,8 @@ static int is_decimal(const char *string, size_t length) { if (length > 2 && !strncmp(string, "-0", 2) && string[2] != '.') { return 0; } - while (length--) { + while (length) { + length--; if (strchr("xX", string[length])) { return 0; }