summaryrefslogtreecommitdiff
path: root/userland/libc/stdlib/strtol.c
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/stdlib/strtol.c')
-rw-r--r--userland/libc/stdlib/strtol.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/userland/libc/stdlib/strtol.c b/userland/libc/stdlib/strtol.c
index 4a1e189..460dedd 100644
--- a/userland/libc/stdlib/strtol.c
+++ b/userland/libc/stdlib/strtol.c
@@ -44,12 +44,15 @@ long strtol(const char *str, char **restrict endptr, int base) {
if (2 <= base && 36 >= base) {
for (; *str; str++) {
+ int val = get_value(*str, base);
+ if (-1 == val) {
+ break;
+ }
if (ret_value > LONG_MAX / base) {
errno = ERANGE;
return LONG_MAX;
}
ret_value *= base;
- int val = get_value(*str, base);
if (ret_value > LONG_MAX - val) {
errno = ERANGE;
return LONG_MAX;