diff options
Diffstat (limited to 'src/external/sinfl.h')
| -rw-r--r-- | src/external/sinfl.h | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/external/sinfl.h b/src/external/sinfl.h index 8979fcd7..915da9d2 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-2023 Micha Mettke +Copyright (c) 2020 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,21 +400,17 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size) } break; case stored: { /* uncompressed block */ - unsigned len, nlen; + int len, nlen; + sinfl_refill(&s); sinfl__get(&s,s.bitcnt & 7); - len = (unsigned short)sinfl__get(&s,16); - nlen = (unsigned short)sinfl__get(&s,16); - s.bitptr -= s.bitcnt / 8; - s.bitbuf = s.bitcnt = 0; + len = sinfl__get(&s,16); + nlen = sinfl__get(&s,16); + in -= 2; s.bitcnt = 0; - if ((unsigned short)len != (unsigned short)~nlen) - return (int)(out-o); - if (len > (e - s.bitptr) || !len) + if (len > (e-in) || !len) return (int)(out-o); - - memcpy(out, s.bitptr, (size_t)len); - s.bitptr += len, out += len; - if (last) return (int)(out-o); + memcpy(out, in, (size_t)len); + in += len, out += len; state = hdr; } break; case fixed: { @@ -447,9 +443,8 @@ 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); - sym = sinfl_decode(&s, hlens, 7); + int 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; @@ -463,9 +458,8 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size) case blk: { /* decompress block */ while (1) { - int sym; sinfl_refill(&s); - sym = sinfl_decode(&s, s.lits, 10); + int sym = sinfl_decode(&s, s.lits, 10); if (sym < 256) { /* literal */ if (sinfl_unlikely(out >= oe)) { |
