summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSun He <sunheehnus@gmail.com>2016-04-06 22:49:29 +0800
committerantirez <antirez@gmail.com>2016-05-10 06:40:06 +0200
commit2e464bf0b110ee225757a5126331a6c25c2317f9 (patch)
treeb1751a63d32dc723ad8a3c25b3546136c2ea6ca5
parent3a7b1702056673d05916574064fdaf6ae84967b1 (diff)
downloadredis-2e464bf0b110ee225757a5126331a6c25c2317f9.tar.gz
modules/RM_StringTruncate: correct reallocate condition
-rw-r--r--src/module.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/module.c b/src/module.c
index e3a7bb857..2dd6c9b63 100644
--- a/src/module.c
+++ b/src/module.c
@@ -747,7 +747,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) {
} else if (newlen < curlen) {
sdsrange(key->value->ptr,0,newlen-1);
/* If the string is too wasteful, reallocate it. */
- if (sdslen(key->value->ptr) > sdsavail(key->value->ptr))
+ if (sdslen(key->value->ptr) < sdsavail(key->value->ptr))
key->value->ptr = sdsRemoveFreeSpace(key->value->ptr);
}
return REDISMODULE_OK;