diff options
author | 2007-01-09 13:20:05 +1000 | |
---|---|---|
committer | 2007-01-09 13:20:05 +1000 | |
commit | b70092e28140dc1725f568d0522e0a26507a0964 (patch) | |
tree | 07235edceca6eba99c437e6ae80c092a17557eb2 /util.c | |
parent | 602eac89c4f446b46d9a4023b06f878f07c3abac (diff) |
Check for errors during string to integer conversion in various places
darcs-hash:20070109032005-ac50b-29514c9c8c19c70b7cfe7670a5c74899f316931f.gz
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -1112,9 +1112,23 @@ int wcsfilecmp( const wchar_t *a, const wchar_t *b ) if( iswdigit( *a ) && iswdigit( *b ) ) { wchar_t *aend, *bend; - long al = wcstol( a, &aend, 10 ); - long bl = wcstol( b, &bend, 10 ); - int diff = al - bl; + long al; + long bl; + int diff; + + errno = 0; + al = wcstol( a, &aend, 10 ); + bl = wcstol( b, &bend, 10 ); + + if( errno ) + { + /* + Huuuuuuuuge numbers - fall back to regular string comparison + */ + return wcscmp( a, b ); + } + + diff = al - bl; if( diff ) return diff>0?2:-2; |