diff tools/lib64gfx.c @ 1797:5204fab92c9e

If the c64 image format has a set size and our buffer after encoding in dmC64EncodeBMP() is smaller than that size, we grow the buffer to match (with zeroed data). This accounts for format variants that are otherwise identical.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 14 Jun 2018 04:00:59 +0300
parents 523c1d1270d6
children 708d333734f9
line wrap: on
line diff
--- a/tools/lib64gfx.c	Thu Jun 14 03:59:45 2018 +0300
+++ b/tools/lib64gfx.c	Thu Jun 14 04:00:59 2018 +0300
@@ -1437,6 +1437,16 @@
     if (res != DMERR_OK)
         goto err;
 
+    // Finally, if the format has a set size and our buffer is smaller
+    // than that size, we grow the buffer to match (with zeroed data).
+    // This accounts for format variants that are otherwise identical.
+    if (fmt->size > 0 && buf->len < fmt->size &&
+        !dmGrowBufCheckGrow(buf, fmt->size))
+    {
+        res = DMERR_MALLOC;
+        goto err;
+    }
+
     return DMERR_OK;
 
 err: