Fix: memory leaks in SVG & WEBP thumbnail loader on error
This commit is contained in:
@@ -54,10 +54,11 @@ ImBuf *imb_load_filepath_thumbnail_svg(const char *filepath,
|
||||
ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_byte_data);
|
||||
if (ibuf != nullptr) {
|
||||
nsvgRasterize(rast, image, 0, 0, scale, ibuf->byte_buffer.data, dest_w, dest_h, dest_w * 4);
|
||||
nsvgDeleteRasterizer(rast);
|
||||
nsvgDelete(image);
|
||||
IMB_flipy(ibuf);
|
||||
}
|
||||
|
||||
nsvgDeleteRasterizer(rast);
|
||||
nsvgDelete(image);
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,8 @@ ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath,
|
||||
|
||||
if (WebPDecode(data, data_size, &config) != VP8_STATUS_OK) {
|
||||
fprintf(stderr, "WebP: Failed to decode image\n");
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
imb_mmap_lock();
|
||||
BLI_mmap_free(mmap_file);
|
||||
imb_mmap_unlock();
|
||||
|
||||
Reference in New Issue
Block a user