From 4129e7e645e19625a5916d968c0a96a2fcccd3bc Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Sun, 3 Aug 2008 18:35:54 +0000 Subject: [PATCH] - Add NULL checks to _atoi64, _wtol, and _wtoi64. - Since atoi, atol, and _wtoi should check for NULL (_tcstol doesn't) but should not check for overflow (_tcstol does), make them call _ttoi64 instead of _tcstol. svn path=/trunk/; revision=35078 --- reactos/lib/sdk/crt/string/atoi.c | 2 +- reactos/lib/sdk/crt/string/atoi64.c | 3 +++ reactos/lib/sdk/crt/string/atol.c | 2 +- reactos/lib/sdk/crt/string/wtoi64.c | 3 +++ reactos/lib/sdk/crt/string/wtol.c | 3 +++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/reactos/lib/sdk/crt/string/atoi.c b/reactos/lib/sdk/crt/string/atoi.c index 74f3175565e..2fc1364dc83 100644 --- a/reactos/lib/sdk/crt/string/atoi.c +++ b/reactos/lib/sdk/crt/string/atoi.c @@ -8,5 +8,5 @@ int _ttoi(const _TCHAR *str) { - return (int)_tcstol(str, 0, 10); + return (int)_ttoi64(str); } diff --git a/reactos/lib/sdk/crt/string/atoi64.c b/reactos/lib/sdk/crt/string/atoi64.c index d97d359ee6f..c820dbaba42 100644 --- a/reactos/lib/sdk/crt/string/atoi64.c +++ b/reactos/lib/sdk/crt/string/atoi64.c @@ -20,6 +20,9 @@ _atoi64(const char *nptr) __int64 acc = 0; int neg = 0; + if (nptr == NULL) + return 0; + while(isspace((int)*s)) s++; if (*s == '-') diff --git a/reactos/lib/sdk/crt/string/atol.c b/reactos/lib/sdk/crt/string/atol.c index cc3fe76cd0e..9aa3af57d87 100644 --- a/reactos/lib/sdk/crt/string/atol.c +++ b/reactos/lib/sdk/crt/string/atol.c @@ -8,7 +8,7 @@ long _ttol(const _TCHAR *str) { - return _tcstol(str, 0, 10); + return (long)_ttoi64(str); } int _atoldbl(long double *value, const char *str) diff --git a/reactos/lib/sdk/crt/string/wtoi64.c b/reactos/lib/sdk/crt/string/wtoi64.c index 6e0f9dbdd64..b729f493a56 100644 --- a/reactos/lib/sdk/crt/string/wtoi64.c +++ b/reactos/lib/sdk/crt/string/wtoi64.c @@ -20,6 +20,9 @@ _wtoi64 (const wchar_t *nptr) __int64 value; int sign; + if (nptr == NULL) + return 0; + while (iswctype((int)*nptr, _SPACE)) ++nptr; diff --git a/reactos/lib/sdk/crt/string/wtol.c b/reactos/lib/sdk/crt/string/wtol.c index 9944956384b..a57015e9f7b 100644 --- a/reactos/lib/sdk/crt/string/wtol.c +++ b/reactos/lib/sdk/crt/string/wtol.c @@ -13,6 +13,9 @@ _wtol(const wchar_t *str) unsigned long RunningTotal = 0; char bMinus = 0; + if (str == NULL) + return 0; + while (iswctype(*str, _SPACE) ) { str++; } /* while */