summaryrefslogtreecommitdiff
path: root/src/hyperloglog.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-12-22 11:26:31 +0100
committerantirez <antirez@gmail.com>2017-12-22 11:26:31 +0100
commit0b561883b48db76a78497b1bebfd9367c80e2d96 (patch)
treedd9c7c09ae9ecbbb5e52c1c188e33f63610c11f0 /src/hyperloglog.c
parent27b81f3fbca03c1d61e6b183317d90bc3dec119b (diff)
downloadredis-0b561883b48db76a78497b1bebfd9367c80e2d96.tar.gz
Hyperloglog: refresh hdr variable correctly.
This is a fix for the #3819 improvements. The o->ptr may change because of hllSparseSet() calls, so 'hdr' must be correctly re-fetched.
Diffstat (limited to 'src/hyperloglog.c')
-rw-r--r--src/hyperloglog.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 65fbfd06a..ef33979a7 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -1347,14 +1347,16 @@ void pfmergeCommand(client *c) {
/* Write the resulting HLL to the destination HLL registers and
* invalidate the cached value. */
- hdr = o->ptr;
for (j = 0; j < HLL_REGISTERS; j++) {
if (max[j] == 0) continue;
+ hdr = o->ptr;
switch(hdr->encoding) {
case HLL_DENSE: hllDenseSet(hdr->registers,j,max[j]); break;
case HLL_SPARSE: hllSparseSet(o,j,max[j]); break;
}
}
+ hdr = o->ptr; /* o->ptr may be different now, as a side effect of
+ last hllSparseSet() call. */
HLL_INVALIDATE_CACHE(hdr);
signalModifiedKey(c->db,c->argv[1]);