diff options
author | Stephan Unverwerth <s.unverwerth@gmx.de> | 2020-04-05 15:32:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 15:32:57 +0200 |
commit | b82a2239c6f32ff26d92ea4568b3751113d6054f (patch) | |
tree | 00986488d4d65c23551d2e3d9e5eea6e54046007 /Libraries/LibC | |
parent | 0403845d3edce9caf6823e0579074f57e9a4b9b9 (diff) | |
download | serenity-b82a2239c6f32ff26d92ea4568b3751113d6054f.zip |
LibC: Fix strtod() parsing of negative exponents (#1645)
Before this fix negative exponents were interpreted as positive.
Diffstat (limited to 'Libraries/LibC')
-rw-r--r-- | Libraries/LibC/stdlib.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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); |