diff --git a/cfg/windows.cfg b/cfg/windows.cfg index 0559a3ab3..a9d5d3901 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -960,7 +960,11 @@ OpenFileMapping CreateNamedPipe CreateEvent + CreateEventA + CreateEventW CreateEventEx + CreateEventExA + CreateEventExW CreateMutex CreateMutexA CreateMutexW @@ -976,6 +980,8 @@ CreateTimerQueue CreateWaitableTimer OpenEvent + OpenEventA + OpenEventW OpenMutex OpenMutexA OpenMutexW @@ -3752,7 +3758,7 @@ HFONT CreateFont( _In_ BOOL bManualReset, _In_ BOOL bInitialState, _In_opt_ LPCTSTR lpName);--> - + false @@ -3775,7 +3781,7 @@ HFONT CreateFont( _In_opt_ LPCTSTR lpName, _In_ DWORD dwFlags, _In_ DWORD dwDesiredAccess);--> - + false @@ -3799,7 +3805,7 @@ HFONT CreateFont( _In_ DWORD dwDesiredAccess, _In_ BOOL bInheritHandle, _In_ LPCTSTR lpName);--> - + false diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index bb21afbf6..e5b028c65 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -59,6 +59,25 @@ void validCode() FreeLibrary(hModule); hModule = GetModuleHandle(NULL); FreeLibrary(hModule); + + // Valid Event usage, no leaks, valid arguments + HANDLE event; + event = CreateEvent(NULL, FALSE, FALSE, NULL); + if (NULL != event) { + SetEvent(event); + CloseHandle(event); + } + event = OpenEvent(EVENT_ALL_ACCESS, FALSE, L"testevent"); + if (NULL != event) { + PulseEvent(event); + SetEvent(event); + CloseHandle(event); + } + event = CreateEventEx(NULL, L"testevent3", CREATE_EVENT_INITIAL_SET, EVENT_MODIFY_STATE); + if (NULL != event) { + ResetEvent(event); + CloseHandle(event); + } } void bufferAccessOutOfBounds() @@ -102,6 +121,17 @@ void nullPointer() HMODULE * phModule = NULL; // cppcheck-suppress nullPointer GetModuleHandleEx(0, NULL, phModule); + + // cppcheck-suppress leakReturnValNotUsed + // cppcheck-suppress nullPointer + OpenEvent(EVENT_ALL_ACCESS, FALSE, NULL); + HANDLE hEvent = NULL; + // cppcheck-suppress nullPointer + PulseEvent(hEvent); + // cppcheck-suppress nullPointer + ResetEvent(hEvent); + // cppcheck-suppress nullPointer + SetEvent(hEvent); } void resourceLeak_CreateSemaphoreA() @@ -162,6 +192,30 @@ void resourceLeak_LoadLibrary() // cppcheck-suppress resourceLeak } +void resourceLeak_CreateEvent() +{ + HANDLE hEvent; + hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + SetEvent(hEvent); + // cppcheck-suppress resourceLeak +} + +void resourceLeak_CreateEventExA() +{ + HANDLE hEvent; + // cppcheck-suppress unreadVariable + hEvent = CreateEventExA(NULL, "test", CREATE_EVENT_INITIAL_SET, EVENT_MODIFY_STATE); + // cppcheck-suppress resourceLeak +} + +void resourceLeak_OpenEventW() +{ + HANDLE hEvent; + // cppcheck-suppress unreadVariable + hEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, L"testevent"); + // cppcheck-suppress resourceLeak +} + void ignoredReturnValue() { // cppcheck-suppress leakReturnValNotUsed @@ -187,6 +241,13 @@ void ignoredReturnValue() // cppcheck-suppress ignoredReturnValue GetProcAddress(hInstLib, "name"); FreeLibrary(hInstLib); + + // cppcheck-suppress leakReturnValNotUsed + CreateEvent(NULL, FALSE, FALSE, NULL); + // cppcheck-suppress leakReturnValNotUsed + OpenEvent(EVENT_ALL_ACCESS, FALSE, L"testevent"); + // cppcheck-suppress leakReturnValNotUsed + CreateEventEx(NULL, L"test", CREATE_EVENT_INITIAL_SET, EVENT_MODIFY_STATE); } void invalidFunctionArg() @@ -243,6 +304,16 @@ void uninitvar() ReleaseMutex(hMutex); // cppcheck-suppress uninitvar CloseHandle(hMutex); + + HANDLE hEvent; + // cppcheck-suppress uninitvar + PulseEvent(hEvent); + // cppcheck-suppress uninitvar + ResetEvent(hEvent); + // cppcheck-suppress uninitvar + SetEvent(hEvent); + // cppcheck-suppress uninitvar + CloseHandle(hEvent); } void allocDealloc_GetModuleHandleEx()