1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

LibC: Fix strtod() parsing of negative exponents (#1645)

Before this fix negative exponents were interpreted as positive.
This commit is contained in:
Stephan Unverwerth 2020-04-05 15:32:57 +02:00 committed by GitHub
parent 0403845d3e
commit b82a2239c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);