aboutsummaryrefslogtreecommitdiff
path: root/research
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas.ru@gmail.com>2020-08-26 12:32:27 +0200
committerGitHub <noreply@github.com>2020-08-26 12:32:27 +0200
commit223d80cfbec8fd346e32906c732c8ede21f0cea6 (patch)
treede47f73fd7323e327cd9c9f20100da8ed4e13f54 /research
parent0c5603e07bed1d5fbb45e38f9bdf0e4560fde3f0 (diff)
downloadbrotli-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.c1
-rw-r--r--research/draw_histogram.cc25
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;
}