Skip to content

Commit

Permalink
Fix small memory leak in WatcherWin32.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Aug 4, 2024
1 parent c57b51e commit 4335552
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/efsw/WatcherWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,14 @@ void DestroyWatch( WatcherStructWin32* pWatch ) {
CloseHandle( pWatch->Watch->DirHandle );
efSAFE_DELETE_ARRAY( pWatch->Watch->DirName );
efSAFE_DELETE( pWatch->Watch );
efSAFE_DELETE( pWatch );
}
}

/// Starts monitoring a directory.
WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive,
DWORD bufferSize, DWORD notifyFilter, HANDLE iocp ) {
WatcherStructWin32* tWatch;
size_t ptrsize = sizeof( *tWatch );
tWatch = static_cast<WatcherStructWin32*>(
HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, ptrsize ) );

WatcherStructWin32* tWatch = new WatcherStructWin32();
WatcherWin32* pWatch = new WatcherWin32(bufferSize);
if (tWatch)
tWatch->Watch = pWatch;
Expand All @@ -246,7 +243,7 @@ WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive,

CloseHandle( pWatch->DirHandle );
efSAFE_DELETE( pWatch->Watch );
HeapFree( GetProcessHeap(), 0, tWatch );
efSAFE_DELETE( tWatch );
return NULL;
}

Expand Down

0 comments on commit 4335552

Please sign in to comment.