Mercurial > hg > dmlib
changeset 1908:2977baab68db
Fix certain corner case in IFF ByteRun1 encoder.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 26 Jun 2018 16:55:27 +0300 |
parents | 571109a14967 |
children | a323ca23f449 |
files | tools/libgfx.c |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/libgfx.c Tue Jun 26 16:49:03 2018 +0300 +++ b/tools/libgfx.c Tue Jun 26 16:55:27 2018 +0300 @@ -1977,7 +1977,7 @@ if (l_count > *r_count || flush) { size_t count = l_count - *r_count; - Sint8 tmp = count - 1; + Uint8 tmp = count - 1; if (!dmf_write_byte(fp, tmp) || !dmf_write_str(fp, buf + *l_offs, count)) @@ -1987,14 +1987,16 @@ } else { - unsigned int count = *r_count; - Sint8 tmp = -(count - 1); + if (*r_count > 0) + { + unsigned int count = *r_count; + Uint8 tmp = ((Uint8) count - 2) ^ 0xff; - if (!dmf_write_byte(fp, tmp) || - !dmf_write_byte(fp, data)) - return FALSE; - - *r_count = 0; + if (!dmf_write_byte(fp, tmp) || + !dmf_write_byte(fp, data)) + return FALSE; + *r_count = 0; + } *l_offs = offs; }