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:
parent
3d342f72a7
commit
6b1ed26e6a
1 changed files with 6 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue