On 3/12/07, H. Verbeet <hverbeet@gmail.com> wrote:
On 12/03/07, Erich Hoover <ehoover@mines.edu> wrote:
> I think that the allocated memory should be the size of the resource
> multiplied by 4 (instead of adding 4).
What makes you think that?

Just that (pLockedRect->Pitch * pRect->top) with pRect->top = This->currentDesc.Height would return a value 4x that of This->resource.size.

IIRC the +4 there is for dodgy applications reading just past the end
of the surface, but that line could do with a comment in either case.

> I've dug around a bit to see if This->resource.size was just allocated
> incorrectly but that does not appear the case.  So, if someone could confirm
> or deny that this is a typo problem then I'd really appreciate it.
>
Could you look into my comment in bugzilla? I'll probably write a test
for that either way, but it's probably quite a bit faster for you to
check if what I posted there makes any difference.

Dividing pRect->top by 4 seems to solve the problem.  Allocating 4 times as much memory also solves the problem (no apparent visual difference), but your explanation in bugzilla makes sense.  Will you be taking care of this, or should I write up a patch with the divide by 4 and a bounds check?