From 7ad3cea7faf4586bf2bf3f90fbbb18303302f9cb Mon Sep 17 00:00:00 2001 From: antirez Date: Sat, 22 Feb 2025 18:02:53 +0100 Subject: [PATCH] Expr filtering: fix selector name copying. --- expr.c | 6 ++++-- vset.c | 5 ----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/expr.c b/expr.c index fc271f802..6023200e9 100644 --- a/expr.c +++ b/expr.c @@ -629,13 +629,15 @@ int exprRun(exprstate *es, char *json, size_t json_len) { exprtoken *result = RedisModule_Alloc(sizeof(exprtoken)); if (result != NULL && json != NULL) { cJSON *attrib = NULL; - if (parsed_json == NULL) + if (parsed_json == NULL) { parsed_json = cJSON_ParseWithLength(json,json_len); + // Will be left to NULL if the above fails. + } if (parsed_json) { char item_name[128]; if (t->str.len <= sizeof(item_name)) { memcpy(item_name,t->str.start+1,t->str.len-1); - item_name[t->str.len] = 0; + item_name[t->str.len-1] = 0; attrib = cJSON_GetObjectItem(parsed_json,item_name); } /* Fill the token according to the JSON type stored diff --git a/vset.c b/vset.c index 37ecd61fd..8931a592d 100644 --- a/vset.c +++ b/vset.c @@ -573,11 +573,6 @@ int vectorSetFilterCallback(void *value, void *privdata) { if (nv->attrib == NULL) return 0; // No attributes? No match. size_t json_len; char *json = (char*)RedisModule_StringPtrLen(nv->attrib,&json_len); - #if 0 - int res = exprRun(expr,json,json_len); - printf("%s %d\n", json, res); - return res; - #endif return exprRun(expr,json,json_len); }