summaryrefslogtreecommitdiffhomepage
path: root/src/external/sinfl.h
diff options
context:
space:
mode:
authorRay <[email protected]>2023-07-12 15:49:38 +0200
committerRay <[email protected]>2023-07-12 15:49:38 +0200
commitbc9c06325481c0b4b5a2db3b2a8281465569ba3e (patch)
tree4942aa5249838342def7a4151f1164035e1ce80b /src/external/sinfl.h
parent8096f142ecc9607df6b37a924b56202f8eb31657 (diff)
downloadraylib-bc9c06325481c0b4b5a2db3b2a8281465569ba3e.tar.gz
raylib-bc9c06325481c0b4b5a2db3b2a8281465569ba3e.zip
Update external sdefl and sinfl
Diffstat (limited to 'src/external/sinfl.h')
-rw-r--r--src/external/sinfl.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/external/sinfl.h b/src/external/sinfl.h
index 915da9d2..8979fcd7 100644
--- a/src/external/sinfl.h
+++ b/src/external/sinfl.h
@@ -72,7 +72,7 @@ Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
+Copyright (c) 2020-2023 Micha Mettke
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
@@ -400,17 +400,21 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
} break;
case stored: {
/* uncompressed block */
- int len, nlen;
- sinfl_refill(&s);
+ unsigned len, nlen;
sinfl__get(&s,s.bitcnt & 7);
- len = sinfl__get(&s,16);
- nlen = sinfl__get(&s,16);
- in -= 2; s.bitcnt = 0;
+ len = (unsigned short)sinfl__get(&s,16);
+ nlen = (unsigned short)sinfl__get(&s,16);
+ s.bitptr -= s.bitcnt / 8;
+ s.bitbuf = s.bitcnt = 0;
- if (len > (e-in) || !len)
+ if ((unsigned short)len != (unsigned short)~nlen)
+ return (int)(out-o);
+ if (len > (e - s.bitptr) || !len)
return (int)(out-o);
- memcpy(out, in, (size_t)len);
- in += len, out += len;
+
+ memcpy(out, s.bitptr, (size_t)len);
+ s.bitptr += len, out += len;
+ if (last) return (int)(out-o);
state = hdr;
} break;
case fixed: {
@@ -443,8 +447,9 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
/* decode code lengths */
for (n = 0; n < nlit + ndist;) {
+ int sym = 0;
sinfl_refill(&s);
- int sym = sinfl_decode(&s, hlens, 7);
+ sym = sinfl_decode(&s, hlens, 7);
switch (sym) {default: lens[n++] = (unsigned char)sym; break;
case 16: for (i=3+sinfl_get(&s,2);i;i--,n++) lens[n]=lens[n-1]; break;
case 17: for (i=3+sinfl_get(&s,3);i;i--,n++) lens[n]=0; break;
@@ -458,8 +463,9 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
case blk: {
/* decompress block */
while (1) {
+ int sym;
sinfl_refill(&s);
- int sym = sinfl_decode(&s, s.lits, 10);
+ sym = sinfl_decode(&s, s.lits, 10);
if (sym < 256) {
/* literal */
if (sinfl_unlikely(out >= oe)) {