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

LibC: Always assign the offset pointer to endptr in strto{u,}ll()

This patch makes strto{u,}l{l,}() behave more to-spec about endptr.
"If endptr is not NULL, strtoull stores the address of the first invalid
character in *endptr."
This commit is contained in:
AnotherTest 2020-05-12 13:24:25 +04:30 committed by Andreas Kling
parent 3d342f72a7
commit 6b1ed26e6a

View file

@ -929,6 +929,9 @@ long long strtoll(const char* str, char** endptr, int base)
return 0;
}
if (endptr)
*endptr = parse_ptr;
if (overflow) {
errno = ERANGE;
if (sign != Sign::Negative) {
@ -1003,6 +1006,9 @@ unsigned long long strtoull(const char* str, char** endptr, int base)
return 0;
}
if (endptr)
*endptr = parse_ptr;
if (overflow) {
errno = ERANGE;
return LONG_LONG_MAX;