mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Support passing stack allocated module strings to moduleCreateArgvFromUserFormat (#7528)
Specifically, the key passed to the module aof_rewrite callback is a stack allocated robj. When passing it to RedisModule_EmitAOF (with appropriate "s" fmt string) redis used to panic when trying to inc the ref count of the stack allocated robj. Now support such robjs by coying them to a new heap robj. This doesn't affect performance because using the alternative "c" or "b" format strings also copies the input to a new heap robj.
This commit is contained in:
parent
8596d483bc
commit
d484b8a04e
@ -3189,8 +3189,11 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int
|
||||
argv[argc++] = createStringObject(cstr,strlen(cstr));
|
||||
} else if (*p == 's') {
|
||||
robj *obj = va_arg(ap,void*);
|
||||
if (obj->refcount == OBJ_STATIC_REFCOUNT)
|
||||
obj = createStringObject(obj->ptr,sdslen(obj->ptr));
|
||||
else
|
||||
incrRefCount(obj);
|
||||
argv[argc++] = obj;
|
||||
incrRefCount(obj);
|
||||
} else if (*p == 'b') {
|
||||
char *buf = va_arg(ap,char*);
|
||||
size_t len = va_arg(ap,size_t);
|
||||
|
Loading…
Reference in New Issue
Block a user