From f606ee89dd9e8486e88aa4353346ecf178761e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 6 Mar 2017 19:17:53 +0000 Subject: [PATCH] [KERNEL32]: Check for NULL pointer specified to lstrlenA/W and return null length, as specified in the MSDN doc and checked by the tests of r74118. This should remove the unwanted 1st-chance exceptions caught when debugging Office 2010 installation, that calls from time to time lstrlen with NULL pointers. svn path=/trunk/; revision=74119 --- reactos/dll/win32/kernel32/winnls/string/lstring.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/kernel32/winnls/string/lstring.c b/reactos/dll/win32/kernel32/winnls/string/lstring.c index 90e2493a511..3b1d29c511b 100644 --- a/reactos/dll/win32/kernel32/winnls/string/lstring.c +++ b/reactos/dll/win32/kernel32/winnls/string/lstring.c @@ -27,7 +27,8 @@ lstrcmpA(LPCSTR lpString1, LPCSTR lpString2) return 1; Result = CompareStringA(GetThreadLocale(), 0, lpString1, -1, lpString2, -1); - if (Result) Result -= 2; + if (Result) + Result -= 2; return Result; } @@ -56,6 +57,7 @@ lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2) return Result; } + /* * @implemented */ @@ -144,6 +146,9 @@ lstrlenA(LPCSTR lpString) { INT Ret = 0; + if (lpString == NULL) + return 0; + _SEH2_TRY { Ret = strlen(lpString); @@ -292,6 +297,9 @@ lstrlenW(LPCWSTR lpString) { INT Ret = 0; + if (lpString == NULL) + return 0; + _SEH2_TRY { Ret = wcslen(lpString);