musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/stdlib/atoll.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/atoll.c')
-rw-r--r--src/stdlib/atoll.c 5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/stdlib/atoll.c b/src/stdlib/atoll.c
index 0e03e0a1..b6930489 100644
--- a/src/stdlib/atoll.c
+++ b/src/stdlib/atoll.c
@@ -10,7 +10,8 @@ long long atoll(const char *s)
case '-': neg=1;
case '+': s++;
}
+ /* Compute n as a negative number to avoid overflow on LLONG_MIN */
while (isdigit(*s))
- n = 10*n + *s++ - '0';
- return neg ? -n : n;
+ n = 10*n - (*s++ - '0');
+ return neg ? n : -n;
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月23日 15:22:51 +0000

AltStyle によって変換されたページ (->オリジナル) /