diff options
author | antirez <antirez@gmail.com> | 2019-03-15 17:10:16 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2019-03-15 17:10:16 +0100 |
commit | a4b90be9fcd5e1668ac941cabce3b1ab38dbe326 (patch) | |
tree | 7c6bb31985ec3b6aed838e7d95a520b4d91f51a6 /src/hyperloglog.c | |
parent | 4208666797b5831eefc022ae46ab5747200cd671 (diff) | |
download | redis-a4b90be9fcd5e1668ac941cabce3b1ab38dbe326.tar.gz |
HyperLogLog: enlarge reghisto variable for safety.
Diffstat (limited to 'src/hyperloglog.c')
-rw-r--r-- | src/hyperloglog.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c index e993bf26e..526510b43 100644 --- a/src/hyperloglog.c +++ b/src/hyperloglog.c @@ -1017,7 +1017,12 @@ uint64_t hllCount(struct hllhdr *hdr, int *invalid) { double m = HLL_REGISTERS; double E; int j; - int reghisto[HLL_Q+2] = {0}; + /* Note that reghisto could be just HLL_Q+1, becuase this is the + * maximum frequency of the "000...1" sequence the hash function is + * able to return. However it is slow to check for sanity of the + * input: instead we history array at a safe size: overflows will + * just write data to wrong, but correctly allocated, places. */ + int reghisto[64] = {0}; /* Compute register histogram */ if (hdr->encoding == HLL_DENSE) { |