diff options
author | Eugene Kliuchnikov <eustas.ru@gmail.com> | 2020-08-26 12:32:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 12:32:27 +0200 |
commit | 223d80cfbec8fd346e32906c732c8ede21f0cea6 (patch) | |
tree | de47f73fd7323e327cd9c9f20100da8ed4e13f54 /research | |
parent | 0c5603e07bed1d5fbb45e38f9bdf0e4560fde3f0 (diff) | |
download | brotli-223d80cfbec8fd346e32906c732c8ede21f0cea6.zip brotli-223d80cfbec8fd346e32906c732c8ede21f0cea6.tar.gz brotli-223d80cfbec8fd346e32906c732c8ede21f0cea6.tar.bz2 |
Update (#826)
* IMPORTANT: decoder: fix potential overflow when input chunk is >2GiB
* simplify max Huffman table size calculation
* eliminate symbol duplicates (static arrays in .h files)
* minor combing in research/ code
Diffstat (limited to 'research')
-rw-r--r-- | research/brotli_decoder.c | 1 | ||||
-rw-r--r-- | research/draw_histogram.cc | 25 |
2 files changed, 15 insertions, 11 deletions
diff --git a/research/brotli_decoder.c b/research/brotli_decoder.c index b1d556d..4b0bc4a 100644 --- a/research/brotli_decoder.c +++ b/research/brotli_decoder.c @@ -38,6 +38,7 @@ void cleanup(Context* ctx) { void fail(Context* ctx, const char* message) { fprintf(stderr, "%s\n", message); + cleanup(ctx); exit(1); } diff --git a/research/draw_histogram.cc b/research/draw_histogram.cc index b0192a2..6ea4069 100644 --- a/research/draw_histogram.cc +++ b/research/draw_histogram.cc @@ -178,20 +178,23 @@ int main(int argc, char* argv[]) { FILE* fin = fopen(argv[1], "r"); FILE* fout = fopen(argv[2], "wb"); - uint8_t** pixel = new uint8_t*[height]; - int** histo = new int*[height]; - for (int i = 0; i < height; i++) { - pixel[i] = new uint8_t[width]; - histo[i] = new int[width]; - } + if (fin != nullptr && fout != nullptr) { + uint8_t** pixel = new uint8_t*[height]; + int** histo = new int*[height]; + for (int i = 0; i < height; i++) { + pixel[i] = new uint8_t[width]; + histo[i] = new int[width]; + } - BuildHistogram(fin, histo); - fclose(fin); + BuildHistogram(fin, histo); - ConvertToPixels(histo, pixel); + ConvertToPixels(histo, pixel); + + DrawPixels(pixel, fout); + } - DrawPixels(pixel, fout); - fclose(fout); + if (fin) fclose(fin); + if (fout) fclose(fout); return 0; } |