diff --git a/src/model.c b/src/model.c index a13261fe9..cc33fa8f4 100644 --- a/src/model.c +++ b/src/model.c @@ -119,7 +119,7 @@ static void *RAI_Model_RdbLoad(struct RedisModuleIO *io, int encver) { model->infokey = RAI_AddStatsEntry(stats_ctx, stats_keystr, RAI_MODEL, backend, stats_devicestr, stats_tag); - RedisModule_Free(stats_keystr); + RedisModule_FreeString(NULL, stats_keystr); return model; } diff --git a/src/redisai.c b/src/redisai.c index 0205cc954..5402537f6 100644 --- a/src/redisai.c +++ b/src/redisai.c @@ -471,8 +471,9 @@ int RedisAI_ModelGet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_ReplyWithCString(ctx, mto->devicestr); RedisModule_ReplyWithCString(ctx, "tag"); - RedisModuleString *empty_tag = RedisModule_CreateString(ctx, "", 0); + RedisModuleString *empty_tag = RedisModule_CreateString(NULL, "", 0); RedisModule_ReplyWithString(ctx, mto->tag ? mto->tag : empty_tag); + RedisModule_FreeString(NULL, empty_tag); RedisModule_ReplyWithCString(ctx, "batchsize"); RedisModule_ReplyWithLongLong(ctx, (long)mto->opts.batchsize); @@ -546,11 +547,13 @@ int RedisAI_ModelScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv RedisModule_ReplyWithArray(ctx, nkeys); + RedisModuleString *empty_tag = RedisModule_CreateString(NULL, "", 0); for (long long i = 0; i < nkeys; i++) { RedisModule_ReplyWithArray(ctx, 2); RedisModule_ReplyWithString(ctx, keys[i]); - RedisModule_ReplyWithString(ctx, tags[i]); + RedisModule_ReplyWithString(ctx, tags[i] ? tags[i] : empty_tag); } + RedisModule_FreeString(NULL, empty_tag); RedisModule_Free(keys); RedisModule_Free(tags); @@ -787,11 +790,13 @@ int RedisAI_ScriptScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **arg RedisModule_ReplyWithArray(ctx, nkeys); + RedisModuleString *empty_tag = RedisModule_CreateString(NULL, "", 0); for (long long i = 0; i < nkeys; i++) { RedisModule_ReplyWithArray(ctx, 2); RedisModule_ReplyWithString(ctx, keys[i]); - RedisModule_ReplyWithString(ctx, tags[i]); + RedisModule_ReplyWithString(ctx, tags[i] ? tags[i] : empty_tag); } + RedisModule_FreeString(NULL, empty_tag); RedisModule_Free(keys); RedisModule_Free(tags); diff --git a/tests/flow/tests_pytorch.py b/tests/flow/tests_pytorch.py index 03bbb942d..3ba4ea527 100644 --- a/tests/flow/tests_pytorch.py +++ b/tests/flow/tests_pytorch.py @@ -859,7 +859,7 @@ def test_pytorch_modelscan_scriptscan(env): ret = con.execute_command('AI.MODELSET', 'm1', 'TORCH', DEVICE, 'TAG', 'm:v1', 'BLOB', model_pb) env.assertEqual(ret, b'OK') - ret = con.execute_command('AI.MODELSET', 'm2', 'TORCH', DEVICE, 'TAG', 'm:v1', 'BLOB', model_pb) + ret = con.execute_command('AI.MODELSET', 'm2', 'TORCH', DEVICE, 'BLOB', model_pb) env.assertEqual(ret, b'OK') script_filename = os.path.join(test_data_path, 'script.txt') @@ -870,7 +870,7 @@ def test_pytorch_modelscan_scriptscan(env): ret = con.execute_command('AI.SCRIPTSET', 's1', DEVICE, 'TAG', 's:v1', 'SOURCE', script) env.assertEqual(ret, b'OK') - ret = con.execute_command('AI.SCRIPTSET', 's2', DEVICE, 'TAG', 's:v1', 'SOURCE', script) + ret = con.execute_command('AI.SCRIPTSET', 's2', DEVICE, 'SOURCE', script) env.assertEqual(ret, b'OK') ensureSlaveSynced(con, env)