Remove possible overflow in str_comp_filenames (fixes #6204)

This commit is contained in:
Chairn 2022-12-30 00:23:50 +01:00
parent f230ad0bdc
commit ed58668931

View file

@ -2834,8 +2834,7 @@ int str_comp_filenames(const char *a, const char *b)
result = 0; result = 0;
do do
{ {
if(!result) result = *a - *b;
result = *a - *b;
++a; ++a;
++b; ++b;
} while(*a >= '0' && *a <= '9' && *b >= '0' && *b <= '9'); } while(*a >= '0' && *a <= '9' && *b >= '0' && *b <= '9');
@ -2844,7 +2843,7 @@ int str_comp_filenames(const char *a, const char *b)
return 1; return 1;
else if(*b >= '0' && *b <= '9') else if(*b >= '0' && *b <= '9')
return -1; return -1;
else if(result) else
return result; return result;
} }