mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-31 13:00:59 +00:00
- fixed potential memory leak in M_VerifyPNG.
If the 'takereader' parameter is true, the function must delete the reader if it fails before creating the PNGHandle.
This commit is contained in:
parent
690e7d8a84
commit
2ba029ec8d
1 changed files with 4 additions and 0 deletions
|
@ -383,18 +383,22 @@ PNGHandle *M_VerifyPNG (FileReader *filer, bool takereader)
|
|||
|
||||
if (filer->Read(&data, 8) != 8)
|
||||
{
|
||||
if (takereader) delete filer;
|
||||
return NULL;
|
||||
}
|
||||
if (data[0] != MAKE_ID(137,'P','N','G') || data[1] != MAKE_ID(13,10,26,10))
|
||||
{ // Does not have PNG signature
|
||||
if (takereader) delete filer;
|
||||
return NULL;
|
||||
}
|
||||
if (filer->Read (&data, 8) != 8)
|
||||
{
|
||||
if (takereader) delete filer;
|
||||
return NULL;
|
||||
}
|
||||
if (data[1] != MAKE_ID('I','H','D','R'))
|
||||
{ // IHDR must be the first chunk
|
||||
if (takereader) delete filer;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue