Mercurial > hg > dmlib
changeset 1469:0046b4e1b35f
Various fixes in bmp encoding.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 22:30:02 +0300 |
parents | d14d1101616f |
children | 499835ba215c |
files | tools/lib64gfx.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/lib64gfx.c Thu May 10 21:57:20 2018 +0300 +++ b/tools/lib64gfx.c Thu May 10 22:30:02 2018 +0300 @@ -1350,7 +1350,7 @@ { int res = DMERR_OK; - if (buf == NULL || img == NULL || fmt == NULL) + if (img == NULL || fmt == NULL) return DMERR_NULLPTR; // Allocate the output buffer @@ -1361,6 +1361,7 @@ fmt->size); goto err; } + buf->len = fmt->size; // Perform encoding for (int i = 0; i < D64_MAX_ENCDEC_OPS; i++) @@ -1725,15 +1726,18 @@ goto err; // Add the loading address - if ((res = dmGrowBufGrow(buf, 2)) != DMERR_OK) + if (!dmGrowBufGrow(buf, 2)) + { + res = DMERR_MALLOC; goto err; + } memmove(buf->data + 2, buf->data, buf->len); buf->data[0] = DM_GET_ADDR_LO(fmt->addr); buf->data[1] = DM_GET_ADDR_HI(fmt->addr); - buf->len += 2; + return DMERR_OK; err: dmGrowBufFree(buf);