From: Matteo Bruni Subject: [PATCH] d3dx9: Correctly handle sprites array reallocation. Message-Id: <20201120182801.1935913-2-mbruni@codeweavers.com> Date: Fri, 20 Nov 2020 19:28:01 +0100 In-Reply-To: <20201120182801.1935913-1-mbruni@codeweavers.com> References: <20201120182801.1935913-1-mbruni@codeweavers.com> Signed-off-by: Matteo Bruni --- dlls/d3dx9_36/sprite.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/d3dx9_36/sprite.c b/dlls/d3dx9_36/sprite.c index cd244e657ef..bc69aaf02e4 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", @@ -358,8 +359,11 @@ 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, + new_sprites = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->sprites, This->allocated_sprites * sizeof(*This->sprites)); + if (!new_sprites) + return E_OUTOFMEMORY; + This->sprites = new_sprites; } This->sprites[This->sprite_count].texture=texture; if(!(This->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE)) -- 2.26.2