Skip to content

Commit

Permalink
Fix hyperloglog corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSully authored and antirez committed Mar 15, 2019
1 parent 74d6af8 commit 9f13b2b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hyperloglog.c
Expand Up @@ -614,6 +614,10 @@ int hllSparseToDense(robj *o) {
} else {
runlen = HLL_SPARSE_VAL_LEN(p);
regval = HLL_SPARSE_VAL_VALUE(p);
if ((runlen + idx) > HLL_REGISTERS) {
sdsfree(dense);
return C_ERR;
}
while(runlen--) {
HLL_DENSE_SET_REGISTER(hdr->registers,idx,regval);
idx++;
Expand Down Expand Up @@ -1088,6 +1092,8 @@ int hllMerge(uint8_t *max, robj *hll) {
} else {
runlen = HLL_SPARSE_VAL_LEN(p);
regval = HLL_SPARSE_VAL_VALUE(p);
if ((runlen + i) > HLL_REGISTERS)
return C_ERR;
while(runlen--) {
if (regval > max[i]) max[i] = regval;
i++;
Expand Down

0 comments on commit 9f13b2b

Please sign in to comment.