From 3a2694c44130c82aa216c1961d33e50fc1eb53a6 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 29 Apr 2009 01:04:04 +0200 Subject: [PATCH] fix for the LZF off-by-one bug added --- TODO | 1 + redis.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 272b77ca..86de2343 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,6 @@ BEFORE REDIS 1.0.0-rc1 +- TTL command that returns -1 if a key is not volatile otherwise the time to live of a volatile key. - Remove max number of args limit - What happens if the saving child gets killed instead to end normally? Handle this. - Make sinterstore / unionstore / sdiffstore returning the cardinality of the resulting set. diff --git a/redis.c b/redis.c index 9550e290..1237a048 100644 --- a/redis.c +++ b/redis.c @@ -1704,7 +1704,7 @@ static int rdbSaveLzfStringObject(FILE *fp, robj *obj) { /* We require at least four bytes compression for this to be worth it */ outlen = sdslen(obj->ptr)-4; if (outlen <= 0) return 0; - if ((out = zmalloc(outlen)) == NULL) return 0; + if ((out = zmalloc(outlen+1)) == NULL) return 0; comprlen = lzf_compress(obj->ptr, sdslen(obj->ptr), out, outlen); if (comprlen == 0) { zfree(out); @@ -1741,7 +1741,7 @@ static int rdbSaveStringObject(FILE *fp, robj *obj) { /* Try LZF compression - under 20 bytes it's unable to compress even * aaaaaaaaaaaaaaaaaa so skip it */ - if (len > 20) { + if (1 && len > 20) { int retval; retval = rdbSaveLzfStringObject(fp,obj); -- 2.45.2