From b82a2239c6f32ff26d92ea4568b3751113d6054f Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sun, 5 Apr 2020 15:32:57 +0200 Subject: [PATCH] LibC: Fix strtod() parsing of negative exponents (#1645) Before this fix negative exponents were interpreted as positive. --- Libraries/LibC/stdlib.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/LibC/stdlib.cpp b/Libraries/LibC/stdlib.cpp index 925e8882e5..a823ffaf91 100644 --- a/Libraries/LibC/stdlib.cpp +++ b/Libraries/LibC/stdlib.cpp @@ -335,7 +335,9 @@ double strtod(const char* str, char** endptr) } if (str[i] == 'e' || str[i] == 'E') { - if (str[i + 1] == '-' || str[i + 1] == '+') + if (str[i + 1] == '-') + exp_val = -atoi(str + i + 2); + else if (str[i + 1] == '+') exp_val = atoi(str + i + 2); else exp_val = atoi(str + i + 1);