https://bugs.winehq.org/show_bug.cgi?id=48482
--- Comment #15 from Stefan Dösinger stefan@codeweavers.com --- Use after free should be caught by WINEDEBUG=warn+heap.
Add some extra ERR lines to HeapAlloc to make sure you're actually getting a NULL allocation back. If you do, you can see what the parameters are and why it is failing.
If you suspect use after free you can try to make HeapFree do nothing. You might die from out of memory though.
There are other alloc APIs, most importantly VirtualAlloc and GlobalAlloc. But the first one is usually not used for regular work allocations (but e.g. for allocating memory for dynamically generated code or hardware I/O) and GlobalAlloc is more a Win16 thing if I am not mistaken.