From ecc48369ce2f890922e462bfe82e4e26cbb8beba Mon Sep 17 00:00:00 2001 From: Bruce Merry Date: Sat, 29 Sep 2018 21:48:08 +0200 Subject: [PATCH] Fix invalid use of sdsZmallocSize on an embedded string sdsZmallocSize assumes a dynamically allocated SDS. When given a string object created by createEmbeddedStringObject, it calls zmalloc_size on a pointer that isn't the one returned by zmalloc --- src/scripting.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting.c b/src/scripting.c index 73337c71..97915603 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -1221,7 +1221,7 @@ sds luaCreateFunction(client *c, lua_State *lua, robj *body) { * EVALSHA commands as EVAL using the original script. */ int retval = dictAdd(server.lua_scripts,sha,body); serverAssertWithInfo(c ? c : server.lua_client,NULL,retval == DICT_OK); - server.lua_scripts_mem += sdsZmallocSize(sha) + sdsZmallocSize(body->ptr); + server.lua_scripts_mem += sdsZmallocSize(sha) + getStringObjectSdsUsedMemory(body); incrRefCount(body); return sha; }