notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gpu_neon: fix some missing ebuf updates
[pcsx_rearmed.git]
/
deps
/
libchdr
/
src
/
libchdr_huffman.c
diff --git
a/deps/libchdr/src/libchdr_huffman.c
b/deps/libchdr/src/libchdr_huffman.c
index
6a50f13
..
5162b95
100644
(file)
--- a/
deps/libchdr/src/libchdr_huffman.c
+++ b/
deps/libchdr/src/libchdr_huffman.c
@@
-97,7
+97,6
@@
***************************************************************************/
#include <stdlib.h>
***************************************************************************/
#include <stdlib.h>
-#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
@@
-181,7
+180,8
@@
uint32_t huffman_decode_one(struct huffman_decoder* decoder, struct bitstream* b
enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf)
{
enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf)
{
- int numbits, curnode;
+ int numbits;
+ uint32_t curnode;
enum huffman_error error;
/* bits per entry depends on the maxbits */
enum huffman_error error;
/* bits per entry depends on the maxbits */
@@
-212,6
+212,8
@@
enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, stru
else
{
int repcount = bitstream_read(bitbuf, numbits) + 3;
else
{
int repcount = bitstream_read(bitbuf, numbits) + 3;
+ if (repcount + curnode > decoder->numcodes)
+ return HUFFERR_INVALID_DATA;
while (repcount--)
decoder->huffnode[curnode++].numbits = nodebits;
}
while (repcount--)
decoder->huffnode[curnode++].numbits = nodebits;
}
@@
-247,7
+249,7
@@
enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
int last = 0;
int count = 0;
int index;
int last = 0;
int count = 0;
int index;
-
in
t curcode;
+
uint32_
t curcode;
uint8_t rlefullbits = 0;
uint32_t temp;
enum huffman_error error;
uint8_t rlefullbits = 0;
uint32_t temp;
enum huffman_error error;
@@
-317,7
+319,7
@@
enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder)
{
enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder)
{
-
in
t i;
+
uint32_
t i;
uint32_t lowerweight;
uint32_t upperweight;
/* compute the number of data items in the histogram */
uint32_t lowerweight;
uint32_t upperweight;
/* compute the number of data items in the histogram */
@@
-381,7
+383,7
@@
static int huffman_tree_node_compare(const void *item1, const void *item2)
int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint32_t totalweight)
{
int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint32_t totalweight)
{
-
in
t curcode;
+
uint32_
t curcode;
int nextalloc;
int listitems = 0;
int maxbits = 0;
int nextalloc;
int listitems = 0;
int maxbits = 0;
@@
-478,7
+480,8
@@
int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint
enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder)
{
enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder)
{
- int curcode, codelen;
+ uint32_t curcode;
+ int codelen;
uint32_t curstart = 0;
/* build up a histogram of bit lengths */
uint32_t bithisto[33] = { 0 };
uint32_t curstart = 0;
/* build up a histogram of bit lengths */
uint32_t bithisto[33] = { 0 };
@@
-519,7
+522,7
@@
enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decode
void huffman_build_lookup_table(struct huffman_decoder* decoder)
{
void huffman_build_lookup_table(struct huffman_decoder* decoder)
{
-
in
t curcode;
+
uint32_
t curcode;
/* iterate over all codes */
for (curcode = 0; curcode < decoder->numcodes; curcode++)
{
/* iterate over all codes */
for (curcode = 0; curcode < decoder->numcodes; curcode++)
{