# HG changeset patch # User Matti Hamalainen # Date 1530015131 -10800 # Node ID 425259977bc55ab04bf5bc2965467e41e6ca2621 # Parent 5930ff7879b57af706ff99a492fc684a768567f3 Don't use signed arithmatic in IFF ByteRun1 decoder. diff -r 5930ff7879b5 -r 425259977bc5 tools/libgfx.c --- 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))