diff --git a/src/obj_long.c b/src/obj_long.c index 50be538..d7b86be 100644 --- a/src/obj_long.c +++ b/src/obj_long.c @@ -2821,15 +2821,16 @@ KrkValue krk_parse_float(const char * s, size_t l) { union Float { double d; uint64_t i; }; + while (c < l && (s[c] == ' ' || s[c] == '\t' || s[c] == '\n' || s[c] == '\r')) c++; + /* Collect a leading sign. */ if (s[c] == '-') { sign = -1; c++; - ps = 1; } else if (s[c] == '+') { c++; - ps = 1; } + ps = c; /* Case-insensitive check for stringy floats: nan, inf */ if (c + 3 == l) { @@ -2867,6 +2868,8 @@ KrkValue krk_parse_float(const char * s, size_t l) { ee = c; } + while (c < l && (s[c] == ' ' || s[c] == '\t' || s[c] == '\n' || s[c] == '\r')) c++; + /* If we're not at the end here, we have invalid characters. */ if (c != l) return krk_runtimeError(vm.exceptions->valueError, "invalid literal for float");