diff options
Diffstat (limited to 'source/blender/imbuf/intern/allocimbuf.c')
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index ef3743d9c8a..6e9bfa1fc4e 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; @@ -503,7 +506,7 @@ bool IMB_initImBuf(struct ImBuf *ibuf, } /* does no zbuffers? */ -ImBuf *IMB_dupImBuf(ImBuf *ibuf1) +ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) { ImBuf *ibuf2, tbuf; int flags = 0; |