mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Ensure freed image buffer is not propagated
The image data is freed when the image format is unsupported, but `CImageInfo::m_pData` would still point to the freed memory, so double-frees were possible.
This commit is contained in:
parent
82b75ddfe0
commit
f0a17435e6
|
@ -575,8 +575,6 @@ bool CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int St
|
|||
int PngliteIncompatible;
|
||||
if(::LoadPNG(ImageByteBuffer, pFilename, PngliteIncompatible, pImg->m_Width, pImg->m_Height, pImgBuffer, ImageFormat))
|
||||
{
|
||||
pImg->m_pData = pImgBuffer;
|
||||
|
||||
if(ImageFormat == IMAGE_FORMAT_RGB)
|
||||
pImg->m_Format = CImageInfo::FORMAT_RGB;
|
||||
else if(ImageFormat == IMAGE_FORMAT_RGBA)
|
||||
|
@ -587,6 +585,7 @@ bool CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int St
|
|||
log_error("game/png", "image had unsupported image format. filename='%s' format='%d'", pFilename, (int)ImageFormat);
|
||||
return false;
|
||||
}
|
||||
pImg->m_pData = pImgBuffer;
|
||||
|
||||
if(m_WarnPngliteIncompatibleImages && PngliteIncompatible != 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue