From d2e857d83ecfdbc62a6f2c689722a2398d8fb793 Mon Sep 17 00:00:00 2001 From: Zoltan Szabadka Date: Fri, 23 Oct 2015 11:19:04 +0200 Subject: [PATCH] Fix integer overflow and slowness in entropy estimation. --- enc/encode.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enc/encode.cc b/enc/encode.cc index ba813e4..19b8629 100644 --- a/enc/encode.cc +++ b/enc/encode.cc @@ -389,7 +389,7 @@ bool BrotliCompressor::WriteMetaBlockInternal(const bool is_last, static const int kSampleRate = 13; static const double kMinEntropy = 7.92; const double bit_cost_threshold = bytes * kMinEntropy / kSampleRate; - for (int i = last_flush_pos_; i < input_pos_; i += kSampleRate) { + for (size_t i = last_flush_pos_; i < input_pos_; i += kSampleRate) { ++literal_histo[data[i & mask]]; } if (BitsEntropy(literal_histo, 256) > bit_cost_threshold) {