Skip to content

Commit

Permalink
[EXPLORER] WatchList should be freed with delete[], not delete (#374)
Browse files Browse the repository at this point in the history
WatchList is a set of array objects, initialized with "new[]", so it should be freed with "delete[]" to free all of its elements. Otherwise using only "delete" only frees the first variable but not its array. This would lead to an undefined behaviour.
  • Loading branch information
GeoB99 authored and HBelusca committed Feb 11, 2018
1 parent 075d58c commit abdde0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/shell/explorer/syspager.cpp
Expand Up @@ -413,7 +413,7 @@ UINT WINAPI CIconWatcher::WatcherThread(_In_opt_ LPVOID lpParam)
ASSERT(Size <= MAXIMUM_WAIT_OBJECTS);

if (WatchList)
delete WatchList;
delete[] WatchList;
WatchList = new HANDLE[Size];
WatchList[0] = This->m_WakeUpEvent;

Expand Down Expand Up @@ -479,7 +479,7 @@ UINT WINAPI CIconWatcher::WatcherThread(_In_opt_ LPVOID lpParam)
}

if (WatchList)
delete WatchList;
delete[] WatchList;

return 0;
}
Expand Down

0 comments on commit abdde0b

Please sign in to comment.