I'm looking into a problem that causes Supreme Commander to segfault (Bug #7643) and I believe I may have run into a problem with IWineD3DSurfaceImpl_LockRect. I believe the problem is a typo in the line:
This->resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + 4);
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel)the value of pLockedRect->pBits is greater than "This->resource.allocatedMemory + This->resource.size + 4".