wined3d: Don't allow a negative lock_count in buffer_Unmap.

This commit is contained in:
Rico Schüller 2009-06-10 21:54:07 +02:00 committed by Alexandre Julliard
parent 9e5d07bb53
commit 3ea66d6026

View file

@ -985,6 +985,16 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
TRACE("(%p)\n", This);
/* In the case that the number of Unmap calls > the
* number of Map calls, d3d returns always D3D_OK.
* This is also needed to prevent Map from returning garbage on
* the next call (this will happen if the lock_count is < 0). */
if(This->lock_count == 0)
{
TRACE("Unmap called without a previous Map call!\n");
return WINED3D_OK;
}
if (InterlockedDecrement(&This->lock_count))
{
/* Delay loading the buffer until everything is unlocked */