Commit: a4c655848180a8e88c1b19a1be0a96cff66670f2 Author: Bastien Montagne Date: Fri Dec 2 09:44:41 2016 +0100 Branches: master https://developer.blender.org/rBa4c655848180a8e88c1b19a1be0a96cff66670f2
Fix (unreported) memleak in ImBuf mipmap code in some cases. `IMB_remakemipmap` may 'shrink' the mipmap list without actually freeing anything, so we need to check all possible levels in `imb_freemipmapImBuf` to avoid memory leaks, not only those currently used. =================================================================== M source/blender/imbuf/intern/allocimbuf.c =================================================================== diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index ef3743d..3375047 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -89,11 +89,14 @@ void imb_mmap_unlock(void) void imb_freemipmapImBuf(ImBuf *ibuf) { int a; - - for (a = 1; a < ibuf->miptot; a++) { - if (ibuf->mipmap[a - 1]) - IMB_freeImBuf(ibuf->mipmap[a - 1]); - ibuf->mipmap[a - 1] = NULL; + + /* Do not trust ibuf->miptot, in some cases IMB_remakemipmap can leave unfreed unused levels, + * leading to memory leaks... */ + for (a = 0; a < IMB_MIPMAP_LEVELS; a++) { + if (ibuf->mipmap[a] != NULL) { + IMB_freeImBuf(ibuf->mipmap[a]); + ibuf->mipmap[a] = NULL; + } } ibuf->miptot = 0; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs