Browse Source

engine: imagelib: img_png: fix Mem_Free on null ptr

pull/2/head
Alibek Omarov 2 years ago
parent
commit
0e9106685b
  1. 14
      engine/common/imagelib/img_png.c

14
engine/common/imagelib/img_png.c

@ -214,7 +214,7 @@ qboolean Image_LoadPNG( const char *name, const byte *buffer, fs_offset_t filesi @@ -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 @@ -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 @@ -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:

Loading…
Cancel
Save