changeset 833:4f3828914890

Fix a 100L :S
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 Jul 2014 18:02:59 +0300
parents b7dbdacaf01d
children 9623b9b548d4
files src/lib64gfx.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib64gfx.c	Sun Jun 22 07:27:56 2014 +0300
+++ b/src/lib64gfx.c	Fri Jul 11 18:02:59 2014 +0300
@@ -652,11 +652,12 @@
         // Do we need to reallocate some more space?
         if (2 + op->offs + size > allocated)
         {
+            size_t diff = allocated - (op->offs + size + 2),
+                   grow = (diff / (BUF_SIZE_GROW - 1)) * BUF_SIZE_GROW;
+            allocated += grow;
+
             if ((buf = dmRealloc(buf, allocated)) == NULL)
             {
-                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",
                     allocated);
                 res = DMERR_MALLOC;