From 069084d4358b17573ecbcea1d572646f4d6ed089 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 29 Apr 2021 06:44:19 -0400 Subject: [PATCH] auxvec: unite memory release in sprite_rebuild() #1440 --- src/lib/internal.h | 6 +++--- src/lib/kitty.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/internal.h b/src/lib/internal.h index fd9a94d88..4413e7924 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -1001,15 +1001,15 @@ sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){ int ret = 0; // special case the transition back to SPRIXCELL_TRANSPARENT; this can be // done in O(1), since the actual glyph needn't change. + uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector; + assert(auxvec); if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED_TRANS){ s->n->tam[s->dimx * ycell + xcell].state = SPRIXCELL_TRANSPARENT; }else if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){ - uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector; - assert(auxvec); // sets the new state itself ret = nc->tcache.pixel_rebuild(s, ycell, xcell, auxvec); - free(auxvec); } + free(auxvec); s->n->tam[s->dimx * ycell + xcell].auxvector = NULL; return ret; } diff --git a/src/lib/kitty.c b/src/lib/kitty.c index d4b954c27..05be6207c 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -314,7 +314,6 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec){ //fprintf(stderr, "CLEARED ROW, TARGY: %d\n", targy - 1); if(--targy == 0){ s->n->tam[s->dimx * ycell + xcell].state = state; - free(auxvec); return 0; } thisrow = targx;