mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-28 09:05:52 +00:00
loaders jpg: fix all memory leaks.
These were detected by asan with PictureJpg example, fixed them all.
This commit is contained in:
parent
18bf321d2c
commit
246149e91a
2 changed files with 8 additions and 2 deletions
|
@ -47,6 +47,7 @@ JpgLoader::~JpgLoader()
|
|||
{
|
||||
jpgdDelete(decoder);
|
||||
if (freeData) free(data);
|
||||
free(image);
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,5 +129,9 @@ unique_ptr<Surface> JpgLoader::bitmap()
|
|||
|
||||
void JpgLoader::run(unsigned tid)
|
||||
{
|
||||
if (image) {
|
||||
free(image);
|
||||
image = nullptr;
|
||||
}
|
||||
image = jpgdDecompress(decoder);
|
||||
}
|
|
@ -1080,7 +1080,9 @@ namespace DCT_Upsample
|
|||
// Unconditionally frees all allocated m_blocks.
|
||||
void jpeg_decoder::free_all_blocks()
|
||||
{
|
||||
delete(m_pStream);
|
||||
m_pStream = nullptr;
|
||||
|
||||
for (mem_block *b = m_pMem_blocks; b; ) {
|
||||
mem_block *n = b->m_pNext;
|
||||
free(b);
|
||||
|
@ -2815,7 +2817,6 @@ int jpeg_decoder::begin_decoding()
|
|||
jpeg_decoder::~jpeg_decoder()
|
||||
{
|
||||
free_all_blocks();
|
||||
delete(m_pStream);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3025,4 +3026,4 @@ unsigned char* jpgdDecompress(jpeg_decoder* decoder)
|
|||
}
|
||||
}
|
||||
return pImage_data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue