Fix: memory leaks in SVG & WEBP thumbnail loader on error

This commit is contained in:
Campbell Barton
2025-07-01 16:26:34 +10:00
parent 46f23bd066
commit cbfa328327
2 changed files with 5 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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();