Mercurial > hg > dmlib
changeset 954:88cbea0ee9b5
Cleanup.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 26 Feb 2015 19:06:32 +0200 |
parents | 1e65752b5723 |
children | 6b2f41844580 |
files | src/dmzlib.c |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmzlib.c Thu Feb 26 19:00:13 2015 +0200 +++ b/src/dmzlib.c Thu Feb 26 19:06:32 2015 +0200 @@ -64,7 +64,7 @@ } -static int stbi__zbuild_huffman(DMZHuffmanContext * z, Uint8 * sizelist, int num) +static int stbi__zbuild_huffman(DMZHuffmanContext * z, const Uint8 * sizelist, const int num) { int i, k = 0; int code, next_code[16], sizes[17]; @@ -78,7 +78,10 @@ sizes[0] = 0; for (i = 1; i < 16; i++) - STBI_ASSERT(sizes[i] <= (1 << i)); + { + if (sizes[i] > (1 << i)) + return stbi__err("fail!", "omg!"); + } code = 0; for (i = 1; i < 16; i++) @@ -87,9 +90,10 @@ z->firstCode[i] = (Uint16) code; z->firstSymbol[i] = (Uint16) k; code = (code + sizes[i]); - if (sizes[i]) - if (code - 1 >= (1 << i)) - return stbi__err("bad codelengths", "Corrupt JPEG"); + + if (sizes[i] && code - 1 >= (1 << i)) + return stbi__err("bad codelengths", "Corrupt JPEG"); + z->maxCode[i] = code << (16 - i); // preshift for inner loop code <<= 1; k += sizes[i];