Hi VLD developers, I'm a developer of [MinHook](http://www.example.com).
A user of MinHook reported a memory leak. In short, VLD reports a leak when calling HeapDestroy without HeapFree.
Look at the test code below:
```
#include <windows.h>
#include <vld.h>
int main()
{
HANDLE hHeap = HeapCreate(0, 0, 0);
LPVOID pHeap = HeapAlloc(hHeap, 0, 1024);
// Skip HeapFree intentionally.
HeapDestroy(hHeap); // returns TRUE
return 0;
}
```
It causes an error like this:
```
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x010D05B8: 1024 bytes ----------
Call Stack:
d:\users\kageyu\documents\visual studio 2013\projects\heapleak\heapleak\main.cpp (10): HeapLeak.exe!main + 0x13 bytes
f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c (626): HeapLeak.exe!__tmainCRTStartup + 0x19 bytes
f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c (466): HeapLeak.exe!mainCRTStartup
0x748B7C04 (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0x24 bytes
0x76FFB90F (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x8F bytes
0x76FFB8DA (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x5A bytes
Data:
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
Visual Leak Detector detected 1 memory leak in heap 0x010D0000
```
However, according to the [HeapDestroy](http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa366700%28v=vs.85%29.aspx) document:
> Processes can call HeapDestroy without first calling the HeapFree function to free memory allocated from the heap.
So I'm wondering if it is an actual memory leak or a false positive.
A user of MinHook reported a memory leak. In short, VLD reports a leak when calling HeapDestroy without HeapFree.
Look at the test code below:
```
#include <windows.h>
#include <vld.h>
int main()
{
HANDLE hHeap = HeapCreate(0, 0, 0);
LPVOID pHeap = HeapAlloc(hHeap, 0, 1024);
// Skip HeapFree intentionally.
HeapDestroy(hHeap); // returns TRUE
return 0;
}
```
It causes an error like this:
```
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x010D05B8: 1024 bytes ----------
Call Stack:
d:\users\kageyu\documents\visual studio 2013\projects\heapleak\heapleak\main.cpp (10): HeapLeak.exe!main + 0x13 bytes
f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c (626): HeapLeak.exe!__tmainCRTStartup + 0x19 bytes
f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c (466): HeapLeak.exe!mainCRTStartup
0x748B7C04 (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0x24 bytes
0x76FFB90F (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x8F bytes
0x76FFB8DA (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x5A bytes
Data:
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
0D F0 AD BA 0D F0 AD BA 0D F0 AD BA 0D F0 AD BA ........ ........
Visual Leak Detector detected 1 memory leak in heap 0x010D0000
```
However, according to the [HeapDestroy](http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa366700%28v=vs.85%29.aspx) document:
> Processes can call HeapDestroy without first calling the HeapFree function to free memory allocated from the heap.
So I'm wondering if it is an actual memory leak or a false positive.