mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix memory leaks around PNG/sprite handling (#10711)
This commit is contained in:
parent
50567d31ce
commit
38907fd0c7
|
@ -222,7 +222,8 @@ static bool sprite_file_export(int32_t spriteIndex, const char* outPath)
|
|||
|
||||
spriteHeader = &spriteFileEntries[spriteIndex];
|
||||
pixelBufferSize = spriteHeader->width * spriteHeader->height;
|
||||
pixels = (uint8_t*)malloc(pixelBufferSize);
|
||||
std::unique_ptr<uint8_t[]> pixelBuffer(new uint8_t[pixelBufferSize]);
|
||||
pixels = pixelBuffer.get();
|
||||
std::fill_n(pixels, pixelBufferSize, 0x00);
|
||||
|
||||
dpi.bits = pixels;
|
||||
|
|
|
@ -232,6 +232,7 @@ namespace Imaging
|
|||
}
|
||||
|
||||
png_write_end(png_ptr, nullptr);
|
||||
png_destroy_info_struct(png_ptr, &info_ptr);
|
||||
png_free(png_ptr, png_palette);
|
||||
png_destroy_write_struct(&png_ptr, nullptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue