# HG changeset patch # User Matti Hamalainen # Date 1528716069 -10800 # Node ID 9c4b3fecc510e2a5d0eeb370fd7f8fd316b23f8b # Parent 5e928618fdc8321cabe8e26c098e3fee94d3e742 Use the new DMGrowBuf functions in XX2 format buffer enlarging. diff -r 5e928618fdc8 -r 9c4b3fecc510 tools/lib64fmts.c --- a/tools/lib64fmts.c Mon Jun 11 13:57:07 2018 +0300 +++ b/tools/lib64fmts.c Mon Jun 11 14:21:09 2018 +0300 @@ -531,15 +531,13 @@ // If there is only data for less than XX2_MIN_SIZE bytes, // allocate a buffer of that size and copy data there. // Otherwise allocate len bytes. - size_t nlen = buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE : buf->len; - Uint8 *mem = dmMalloc0(nlen); - if (mem == NULL) + if (dmGrowBufCopy(&tmp, buf, buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE - buf->len : 0) == NULL) return DMERR_MALLOC; - memcpy(mem, buf->data, buf->len); - res = dmC64DecodeGenericBMP(img, dmGrowBufCreateFrom(&tmp, mem, nlen), fmt); + tmp.len = tmp.size; + res = dmC64DecodeGenericBMP(img, &tmp, fmt); + dmGrowBufFree(&tmp); - dmFree(mem); return res; }