changeset 2518:470631c00c97

Implement optionality of loading address in dmC64EncodeBMP() as well.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 May 2020 20:49:12 +0300
parents 106f4426c729
children 4dbb6572622d
files tools/lib64gfx.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Tue May 12 20:31:23 2020 +0300
+++ b/tools/lib64gfx.c	Tue May 12 20:49:12 2020 +0300
@@ -1631,9 +1631,13 @@
     if ((res = dmGrowBufAlloc(buf, BUF_SIZE_INITIAL, BUF_SIZE_GROW)) != DMERR_OK)
         goto out;
 
-    // Add the loading address
-    if (!dmGrowBufPutU16LE(buf, fmt->addr))
+    // Add the loading address, if needed
+    if (fmt->addr >= 0 &&
+        !dmGrowBufPutU16LE(buf, fmt->addr))
+    {
+        res = DMERR_MALLOC;
         goto out;
+    }
 
     // Attempt to encode the image to a buffer
     if (fmt->encode != NULL)