diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-05-12 13:24:25 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-12 13:28:57 +0200 |
commit | 6b1ed26e6aaaacfe83ee0a26ec79b378aa7e376b (patch) | |
tree | d3490b1a055ec831554248af205485d2f81ff5e8 /Libraries/LibC/stdlib.cpp | |
parent | 3d342f72a76b70fcee8872da081a19f7ea229eec (diff) | |
download | serenity-6b1ed26e6aaaacfe83ee0a26ec79b378aa7e376b.zip |
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."
Diffstat (limited to 'Libraries/LibC/stdlib.cpp')
-rw-r--r-- | Libraries/LibC/stdlib.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibC/stdlib.cpp b/Libraries/LibC/stdlib.cpp index 263ad272b9..139f484475 100644 --- a/Libraries/LibC/stdlib.cpp +++ b/Libraries/LibC/stdlib.cpp @@ -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; |