From c83985c5ce7acca8b342dccd7aa77b4760f83aca Mon Sep 17 00:00:00 2001 From: Fotis Panagiotopoulos Date: Mon, 29 Aug 2022 15:53:03 +0300 Subject: [PATCH] Fixes in strtod parser. --- libs/libc/stdlib/lib_strtod.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/libc/stdlib/lib_strtod.c b/libs/libc/stdlib/lib_strtod.c index 57f60787bb2..358eb5aec23 100644 --- a/libs/libc/stdlib/lib_strtod.c +++ b/libs/libc/stdlib/lib_strtod.c @@ -160,6 +160,7 @@ double strtod(FAR const char *str, FAR char **endptr) { set_errno(ERANGE); number = 0.0; + p = (FAR char *)str; goto errout; } @@ -195,6 +196,14 @@ double strtod(FAR const char *str, FAR char **endptr) /* Process string of digits */ + if (!isdigit(*p)) + { + set_errno(ERANGE); + number = 0.0; + p = (FAR char *)str; + goto errout; + } + n = 0; while (isdigit(*p)) {