summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-12 23:55:29 +0200
committerantirez <antirez@gmail.com>2014-04-16 15:26:27 +0200
commitf12fb49bb2fa4f10679c9d7ad6d1540eb8b55861 (patch)
tree1196b9a0c259b87b327df1f2f0a15679f83537f5
parenta3e2adc0ae7cebf38026bc8f79d00dac51839331 (diff)
downloadredis-f12fb49bb2fa4f10679c9d7ad6d1540eb8b55861.tar.gz
Fix hllSparseAdd() new sequence replacement when next is NULL.
sdsIncrLen() must be called anyway even if we are replacing the last oppcode of the sparse representation.
-rw-r--r--src/hyperloglog.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 119cbab1c..5a19443b4 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -784,10 +784,8 @@ int hllSparseAdd(robj *o, unsigned char *ele, size_t elesize) {
int deltalen = seqlen-oldlen;
if (deltalen > 0 && sdslen(o->ptr) > HLL_SPARSE_MAX) goto promote;
- if (deltalen && next) {
- memmove(next+deltalen,next,next-sparse);
- sdsIncrLen(o->ptr,deltalen);
- }
+ if (deltalen && next) memmove(next+deltalen,next,next-sparse);
+ sdsIncrLen(o->ptr,deltalen);
memcpy(p,seq,seqlen);
updated: