unsigned long long strtoull(const char *str, char **end, int base)
{
- long long ret = 0;
+ unsigned long long ret = 0;
if( !str || base < 0 || base > 36 || base == 1 ) {
if(end)
//_SysDebug("strtoll - neg=%i,ret=%llu", neg, ret);
if( neg ) {
- if( -ret < LLONG_MIN ) {
+ // Abuses unsigned integer overflow
+ if( ret + LLONG_MIN < ret ) {
errno = ERANGE;
return LLONG_MIN;
}