Mercurial > hg > dmlib
changeset 1506:4fd4e7a00db4
Fix handling of predefined DMGrowBuffer in dmC64EncodeGenericBMP().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 May 2018 20:27:16 +0300 |
parents | 3265175b24d2 |
children | 7d012e5acf5c |
files | tools/lib64gfx.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/lib64gfx.c Fri May 11 20:18:14 2018 +0300 +++ b/tools/lib64gfx.c Fri May 11 20:27:16 2018 +0300 @@ -697,6 +697,7 @@ int dmC64EncodeGenericBMP(const BOOL allocate, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) { int res = DMERR_OK; + size_t boffs; if (img == NULL || fmt == NULL) return DMERR_NULLPTR; @@ -710,6 +711,8 @@ goto err; } + boffs = buf->len; + // Perform encoding for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++) { @@ -735,7 +738,7 @@ } // Do we need to reallocate some more space? - chksize = op->offs + size; + chksize = op->offs + size + boffs; if (!dmGrowBufCheckGrow(buf, chksize)) { res = dmError(DMERR_MALLOC, @@ -748,7 +751,7 @@ buf->len = chksize; // Perform operation - Uint8 *dst = buf->data + op->offs; + Uint8 *dst = buf->data + boffs + op->offs; switch (op->type) { case DT_COLOR_RAM: memcpy(dst, img->color[op->bank], size); break;