Matteo Bruni : d3dx9: Correctly handle sprites array reallocation.
Alexandre Julliard
julliard at winehq.org
Mon Nov 23 15:43:24 CST 2020
Module: wine
Branch: master
Commit: 34c0055cfcb84e32d13556b7ec841d01acf5fe96
URL: https://source.winehq.org/git/wine.git/?a=commit;h=34c0055cfcb84e32d13556b7ec841d01acf5fe96
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Mon Nov 23 17:14:04 2020 +0100
d3dx9: Correctly handle sprites array reallocation.
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3dx9_36/sprite.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/sprite.c b/dlls/d3dx9_36/sprite.c
index cd244e657ef..5499904da24 100644
--- a/dlls/d3dx9_36/sprite.c
+++ b/dlls/d3dx9_36/sprite.c
@@ -342,6 +342,7 @@ static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *t
const RECT *rect, const D3DXVECTOR3 *center, const D3DXVECTOR3 *position, D3DCOLOR color)
{
struct d3dx9_sprite *This = impl_from_ID3DXSprite(iface);
+ struct sprite *new_sprites;
D3DSURFACE_DESC texdesc;
TRACE("iface %p, texture %p, rect %s, center %p, position %p, color 0x%08x.\n",
@@ -357,9 +358,12 @@ static HRESULT WINAPI d3dx9_sprite_Draw(ID3DXSprite *iface, IDirect3DTexture9 *t
}
else if (This->allocated_sprites <= This->sprite_count)
{
- This->allocated_sprites += This->allocated_sprites / 2;
- This->sprites = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- This->sprites, This->allocated_sprites * sizeof(*This->sprites));
+ new_sprites = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ This->sprites, This->allocated_sprites * 2 * sizeof(*This->sprites));
+ if (!new_sprites)
+ return E_OUTOFMEMORY;
+ This->sprites = new_sprites;
+ This->allocated_sprites *= 2;
}
This->sprites[This->sprite_count].texture=texture;
if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE))
More information about the wine-cvs
mailing list