X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fstdlib%2Fatoll.c;h=b69304895a35c9143ec27ac61ec3a2d24c7a5a59;hp=0e03e0a1a9496b9c8e041c7a26fd4d63b1174bd3;hb=0c4188f6d76fad021a93eb1012630c717bda80a1;hpb=3ed8c9f2df0b5f0bfe1006037c46d4f32ec6ca7b 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; }