mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39: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
Notes:
sideshowbarker
2024-07-19 06:43:02 +09:00
Author: https://github.com/alimpfard
Commit: 6b1ed26e6a
Pull-request: https://github.com/SerenityOS/serenity/pull/2197
Reviewed-by: https://github.com/awesomekling
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