From 21abf315b3f14c37dbca3dcc51e133f80278b5cf Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sun, 17 Oct 2021 11:05:19 +0200 Subject: [PATCH] windows.cfg: Added a regression test for GetPrivateProfileString() as we had a FP in the past https://github.com/danmar/cppcheck/commit/8b6c14aa4880867480d9e4bcd0dc8d5a9f5c3856 --- test/cfg/windows.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index cb62468d2..250532b81 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -87,6 +87,28 @@ void invalidFunctionArg__getcwd(char * buffer) } free(buffer); } +// DWORD GetPrivateProfileString( +// [in] LPCTSTR lpAppName, +// [in] LPCTSTR lpKeyName, +// [in] LPCTSTR lpDefault, +// [out] LPTSTR lpReturnedString, +// [in] DWORD nSize, +// [in] LPCTSTR lpFileName) +void nullPointer_GetPrivateProfileString(LPCTSTR lpAppName, + LPCTSTR lpKeyName, + LPCTSTR lpDefault, + LPTSTR lpReturnedString, + DWORD nSize, + LPCTSTR lpFileName) +{ + // No warning is expected + (void)GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, lpFileName); + + // No warning is expected for 1st arg as nullptr + (void)GetPrivateProfileString(nullptr, lpKeyName, lpDefault, lpReturnedString, nSize, lpFileName); + // No warning is expected for 2st arg as nullptr + (void)GetPrivateProfileString(lpAppName, nullptr, lpDefault, lpReturnedString, nSize, lpFileName); +} void nullPointer__get_timezone(long *sec) {