I&#39;m looking into a problem that causes Supreme Commander to segfault (<a href="http://bugs.winehq.org/show_bug.cgi?id=7643">Bug #7643</a>) and I believe I may have run into a problem with IWineD3DSurfaceImpl_LockRect.&nbsp; I believe the problem is a typo in the line:
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">This-&gt;resource.allocatedMemory = HeapAlloc(GetProcessHeap() ,0 , This-&gt;resource.size
 + 4);</blockquote><div><br>I think that the allocated memory should be the size of the resource multiplied by 4 (instead of adding 4).&nbsp; With the current allocation, for some textures, the operation to calculate the pBits location returns a memory address that is past the end of the allocated memory. So, after this operation:
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">pLockedRect-&gt;pBits = This-&gt;resource.allocatedMemory + (pLockedRect-&gt;Pitch * pRect-&gt;top) + (pRect-&gt;left * This-&gt;bytesPerPixel)
<br></blockquote>the value of pLockedRect-&gt;pBits is greater than &quot;This-&gt;resource.allocatedMemory + This-&gt;resource.size + 4&quot;.</div><br>I&#39;ve dug around a bit to see if This-&gt;resource.size was just allocated incorrectly but that does not appear the case.&nbsp; So, if someone could confirm or deny that this is a typo problem then I&#39;d really appreciate it.
<br><br>Erich Hoover<br><a href="mailto:ehoover@mines.edu">ehoover@mines.edu</a><br>