changeset 1905:425259977bc5

Don't use signed arithmatic in IFF ByteRun1 decoder.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 26 Jun 2018 15:12:11 +0300
parents 5930ff7879b5
children 09d46bf9fe71
files tools/libgfx.c
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Tue Jun 26 13:22:20 2018 +0300
+++ b/tools/libgfx.c	Tue Jun 26 15:12:11 2018 +0300
@@ -1532,21 +1532,20 @@
     size_t offs = 0;
     do
     {
-        Sint8 dcount;
-        Uint8 data;
+        Uint8 data, ucount;
 
-        if (!dmf_read_byte(fp, (Uint8 *) &dcount))
+        if (!dmf_read_byte(fp, &ucount))
             return FALSE;
 
-        if (dcount == -128)
+        if (ucount == 0x80)
         {
             if (!dmf_read_byte(fp, &data))
                 return FALSE;
         }
         else
-        if (dcount < 0)
+        if (ucount & 0x80)
         {
-            int count = (-dcount) + 1;
+            Uint8 count = (ucount ^ 0xff) + 2;
             if (!dmf_read_byte(fp, &data))
                 return FALSE;
 
@@ -1555,7 +1554,7 @@
         }
         else
         {
-            int count = dcount + 1;
+            Uint8 count = ucount + 1;
             while (count-- && offs < bufLen)
             {
                 if (!dmf_read_byte(fp, &data))