Fixed scanning a negative number as an unsigned value
e.g. sscanf("-1", "%zu", &v) Thanks to @sezero for the test casemain
parent
3f5c46663e
commit
2a8d00634d
|
@ -105,6 +105,10 @@ SDL_ScanUnsignedLong(const char *text, int count, int radix, unsigned long *valu
|
||||||
const char *textstart = text;
|
const char *textstart = text;
|
||||||
unsigned long value = 0;
|
unsigned long value = 0;
|
||||||
|
|
||||||
|
if (*text == '-') {
|
||||||
|
return SDL_ScanLong(text, count, radix, (long *)valuep);
|
||||||
|
}
|
||||||
|
|
||||||
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
|
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
|
||||||
text += 2;
|
text += 2;
|
||||||
}
|
}
|
||||||
|
@ -218,6 +222,10 @@ SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 * valuep
|
||||||
const char *textstart = text;
|
const char *textstart = text;
|
||||||
Uint64 value = 0;
|
Uint64 value = 0;
|
||||||
|
|
||||||
|
if (*text == '-') {
|
||||||
|
return SDL_ScanLongLong(text, count, radix, (Sint64 *)valuep);
|
||||||
|
}
|
||||||
|
|
||||||
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
|
if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) {
|
||||||
text += 2;
|
text += 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue