mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
loader png external: fix potential memory leak if read fails
This commit is contained in:
parent
cc173c1fb2
commit
b033cfabbd
1 changed files with 4 additions and 1 deletions
|
@ -93,7 +93,10 @@ bool PngLoader::read()
|
||||||
png_image_free(image);
|
png_image_free(image);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!png_image_finish_read(image, NULL, buffer, 0, NULL)) return false;
|
if (!png_image_finish_read(image, NULL, buffer, 0, NULL)) {
|
||||||
|
free(buffer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
content = reinterpret_cast<uint32_t*>(buffer);
|
content = reinterpret_cast<uint32_t*>(buffer);
|
||||||
|
|
||||||
_premultiply(reinterpret_cast<uint32_t*>(buffer), image->width, image->height);
|
_premultiply(reinterpret_cast<uint32_t*>(buffer), image->width, image->height);
|
||||||
|
|
Loading…
Add table
Reference in a new issue