changeset 1518:24b8b452925e

Improve error handling of RLE encoder.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 23:11:16 +0300
parents 1be17c662b8e
children 19b5013ff190
files tools/lib64gfx.c
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Fri May 11 23:10:21 2018 +0300
+++ b/tools/lib64gfx.c	Fri May 11 23:11:16 2018 +0300
@@ -377,11 +377,7 @@
         if (data != prev || count >= cfg->rleMaxCount)
         {
             if (!dmEncodeGenericRLESequence(dst, prev, count, cfg))
-            {
-                res = dmError(DMERR_MALLOC,
-                    "Could reallocate memory for RLE encoding buffer.\n");
                 goto err;
-            }
 
             count = 1;
         }
@@ -391,10 +387,14 @@
         prev = data;
     }
 
-    res = DMERR_OK;
+    if (!dmEncodeGenericRLESequence(dst, prev, count, cfg))
+        goto err;
+
+    return DMERR_OK;
 
 err:
-    return res;
+     return dmError(DMERR_MALLOC,
+        "Could reallocate memory for RLE encoding buffer.\n");
 }