engine: imagelib: img_png: fix Mem_Free on null ptr

This commit is contained in:
Alibek Omarov 2022-12-05 06:13:04 +03:00
parent 9b001987e9
commit 0e9106685b
1 changed files with 7 additions and 7 deletions

View File

@ -214,7 +214,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
if( ntohl( crc32 ) != crc32_check )
{
Con_DPrintf( S_ERROR "Image_LoadPNG: Found chunk with wrong CRC32 sum (%s)\n", name );
Mem_Free( idat_buf );
if( idat_buf ) Mem_Free( idat_buf );
return false;
}
@ -222,6 +222,12 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
buf_p += sizeof( crc32 );
}
if( oldsize == 0 )
{
Con_DPrintf( S_ERROR "Image_LoadPNG: Couldn't find IDAT chunks (%s)\n", name );
return false;
}
if( png_hdr.ihdr_chunk.colortype == PNG_CT_PALLETE && !pallete )
{
Con_DPrintf( S_ERROR "Image_LoadPNG: PLTE chunk not found (%s)\n", name );
@ -243,12 +249,6 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi
return false;
}
if( oldsize == 0 )
{
Con_DPrintf( S_ERROR "Image_LoadPNG: Couldn't find IDAT chunks (%s)\n", name );
return false;
}
switch( png_hdr.ihdr_chunk.colortype )
{
case PNG_CT_GREY: