diff --git a/cfg/windows.cfg b/cfg/windows.cfg index a9d5d3901..6675cc860 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -1171,6 +1171,11 @@ CoTaskMemAlloc CoTaskMemFree + + _malloca + + _freea + false @@ -4132,6 +4137,35 @@ HFONT CreateFont( + + + + false + + + 0: + + + + + + false + + + + 0: + + + + + false + + + + diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index e5b028c65..71bcacd8a 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -78,6 +78,12 @@ void validCode() ResetEvent(event); CloseHandle(event); } + + void *pMem1 = _malloca(1); + _freea(pMem1); + // Memory from _alloca must not be freed + void *pMem2 = _alloca(10); + memset(pMem2, 0, 10); } void bufferAccessOutOfBounds() @@ -134,6 +140,13 @@ void nullPointer() SetEvent(hEvent); } +void memleak_malloca() +{ + // cppcheck-suppress unreadVariable + void *pMem = _malloca(10); + // cppcheck-suppress memleak +} + void resourceLeak_CreateSemaphoreA() { HANDLE hSemaphore; @@ -248,6 +261,11 @@ void ignoredReturnValue() OpenEvent(EVENT_ALL_ACCESS, FALSE, L"testevent"); // cppcheck-suppress leakReturnValNotUsed CreateEventEx(NULL, L"test", CREATE_EVENT_INITIAL_SET, EVENT_MODIFY_STATE); + + // cppcheck-suppress leakReturnValNotUsed + _malloca(10); + // cppcheck-suppress ignoredReturnValue + _alloca(5); } void invalidFunctionArg() @@ -281,6 +299,13 @@ void invalidFunctionArg() // cppcheck-suppress invalidFunctionArg HINSTANCE hInstLib = LoadLibraryEx(L"My.dll", 1, 0); FreeLibrary(hInstLib); + + // cppcheck-suppress invalidFunctionArg + void *pMem = _malloca(-1); + _freea(pMem); + // cppcheck-suppress unreadVariable + // cppcheck-suppress invalidFunctionArg + pMem = _alloca(-5); } void uninitvar()