Mercurial > hg > dmlib
changeset 536:18fc2890ba4b
Take loading address into account while encoding, so start other data from offset +2.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Nov 2012 22:16:06 +0200 |
parents | ab8d9696225c |
children | 32d9e67da189 |
files | lib64gfx.c |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lib64gfx.c Thu Nov 22 22:15:34 2012 +0200 +++ b/lib64gfx.c Thu Nov 22 22:16:06 2012 +0200 @@ -635,7 +635,7 @@ for (i = 0; i < fmt->nencdecOps; i++) { const DMC64EncDecOp *op = &fmt->encdecOps[i]; - Uint8 *dst = buf + op->offs; + Uint8 *dst = 2 + buf + op->offs; size_t size; if ((res = dmC64SanityCheckEncDecOp(i, op)) != DMERR_OK) @@ -643,11 +643,11 @@ size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; - if (op->offs + size > allocated) + if (2 + op->offs + size > allocated) { if ((buf = dmRealloc(buf, allocated)) == NULL) { - size_t diff = allocated - (op->offs + size), + size_t diff = allocated - (op->offs + size + 2), grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW; allocated = allocated + grow; dmError("Could not re-allocate %d bytes of memory for C64 image encoding buffer.\n", @@ -657,8 +657,8 @@ } } - if (fmt->size == 0 && op->offs + size > *plen) - *plen = op->offs + size; + if (fmt->size == 0 && op->offs + size + 2 > *plen) + *plen = op->offs + size + 2; switch (op->type) {