Skip to content
Permalink
Browse files

Handle allocation failure in CLuaDrawingDefs::DxGetTexturePixels

Solves crash offset 002133f8 (x9575 in revision 20288)
  • Loading branch information...
botder committed Oct 6, 2019
1 parent 1bffa47 commit 08e7f048c6b04c8bff0bbe311d4c4a63c6b5a879
Showing with 22 additions and 2 deletions.
  1. +11 −1 Client/core/Graphics/CPixelsManager.cpp
  2. +11 −1 Client/core/Graphics/CPixelsManager_VolumeTexture.cpp
@@ -278,7 +278,17 @@ bool CPixelsManager::GetSurfacePixels(IDirect3DSurface9* pD3DSurface, CPixels& o

// Prepare pixels
uint ulPixelsPitch = uiPixelsWidth * XRGB_BYTES_PER_PIXEL;
outPixels.SetSize(ulPixelsPitch * uiPixelsHeight + SIZEOF_PLAIN_TAIL);

try
{
outPixels.SetSize(ulPixelsPitch * uiPixelsHeight + SIZEOF_PLAIN_TAIL);
}
catch (const std::bad_alloc&)
{
pD3DSurface->UnlockRect();
return false;
}

memset(outPixels.GetData(), 0x81, outPixels.GetSize());
char* pPixelsData = outPixels.GetData();
pPixelsData += PixelsRect.left * XRGB_BYTES_PER_PIXEL;
@@ -150,7 +150,17 @@ bool CPixelsManager::GetVolumePixels(IDirect3DVolume9* pD3DSurface, CPixels& out

// Prepare pixels
uint ulPixelsPitch = uiPixelsWidth * XRGB_BYTES_PER_PIXEL;
outPixels.SetSize(ulPixelsPitch * uiPixelsHeight + SIZEOF_PLAIN_TAIL);

try
{
outPixels.SetSize(ulPixelsPitch * uiPixelsHeight + SIZEOF_PLAIN_TAIL);
}
catch (const std::bad_alloc&)
{
pD3DSurface->UnlockBox();
return false;
}

memset(outPixels.GetData(), 0x81, outPixels.GetSize());
char* pPixelsData = outPixels.GetData();
pPixelsData += PixelsRect.left * XRGB_BYTES_PER_PIXEL;

0 comments on commit 08e7f04

Please sign in to comment.
You can’t perform that action at this time.