# HG changeset patch # User Matti Hamalainen # Date 1506110432 -10800 # Node ID 0d61895e1763bb1d56fa7b555e4ca0cae07e52f0 # Parent 3af0057f377d5305fc51a019b74706b0313fd822 Cleanup. diff -r 3af0057f377d -r 0d61895e1763 tools/lib64gfx.c --- a/tools/lib64gfx.c Fri Sep 22 16:40:43 2017 +0300 +++ b/tools/lib64gfx.c Fri Sep 22 23:00:32 2017 +0300 @@ -908,7 +908,7 @@ { const DMC64EncDecOp *op = &fmt->encdecOps[i]; Uint8 *dst = 2 + buf + op->offs; - size_t size; + size_t size, chksize; // Check operation validity if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) @@ -925,9 +925,10 @@ } // Do we need to reallocate some more space? - if (2 + op->offs + size > allocated) + chksize = op->offs + size + 2; + if (chksize > allocated) { - size_t diff = allocated - (op->offs + size + 2), + size_t diff = allocated - chksize, grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; allocated += grow; @@ -941,8 +942,8 @@ } } - if (fmt->size == 0 && op->offs + size + 2 > *plen) - *plen = op->offs + size + 2; + if (fmt->size == 0 && chksize > *plen) + *plen = chksize; // Perform operation switch (op->type)