Module: wine Branch: master Commit: 3ea66d6026a208f5fc551cd9a5bb421d2adfa4e3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3ea66d6026a208f5fc551cd9a5...
Author: Rico Schüller kgbricola@web.de Date: Wed Jun 10 21:54:07 2009 +0200
wined3d: Don't allow a negative lock_count in buffer_Unmap.
---
dlls/wined3d/buffer.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 666de8e..e9f3ff6 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -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 */