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.
This commit is contained in:
parent
0e1cf858a0
commit
a4c6558481
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue