mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibC: Fix strtol() not setting endptr correctly for "0"
"0" was interpreted as a base-8 prefix, and the parse pointer was then unconditionally advanced, causing us to consume zero characters. This unbreaks the git port. :^) (We should really have tests for LibC..)
This commit is contained in:
parent
b8d3dbcf2d
commit
08c05fbbd1
1 changed files with 2 additions and 4 deletions
|
@ -873,8 +873,7 @@ long long strtoll(const char* str, char** endptr, int base)
|
|||
// Parse base
|
||||
if (base == 0) {
|
||||
if (*parse_ptr == '0') {
|
||||
parse_ptr += 1;
|
||||
if (*parse_ptr == 'x' || *parse_ptr == 'X') {
|
||||
if (tolower(*(parse_ptr + 1)) == 'x') {
|
||||
base = 16;
|
||||
parse_ptr += 2;
|
||||
} else {
|
||||
|
@ -950,8 +949,7 @@ unsigned long long strtoull(const char* str, char** endptr, int base)
|
|||
// Parse base
|
||||
if (base == 0) {
|
||||
if (*parse_ptr == '0') {
|
||||
parse_ptr += 1;
|
||||
if (*parse_ptr == 'x' || *parse_ptr == 'X') {
|
||||
if (tolower(*(parse_ptr + 1)) == 'x') {
|
||||
base = 16;
|
||||
parse_ptr += 2;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue