@@ -447,7 +447,7 @@ int RedisAI_DagRun_Reply(RedisModuleCtx *ctx, RedisModuleString **argv,
447447 RedisModule_ReplyWithError (ctx , "ERR could not save tensor" );
448448 rinfo -> dagReplyLength ++ ;
449449 } else {
450- if (RedisModule_ModuleTypeSetValue (key , RedisAI_TensorType , tensor ) !=
450+ if (RedisModule_ModuleTypeSetValue (key , RedisAI_TensorType , RAI_TensorGetShallowCopy ( tensor ) ) !=
451451 REDISMODULE_OK ) {
452452 RedisModule_ReplyWithError (ctx , "ERR could not save tensor" );
453453 rinfo -> dagReplyLength ++ ;
@@ -473,6 +473,7 @@ int RedisAI_DagRun_Reply(RedisModuleCtx *ctx, RedisModuleString **argv,
473473 localcontext_key_name );
474474 local_entry = AI_dictNext (local_iter );
475475 }
476+ AI_dictReleaseIterator (local_iter );
476477
477478 for (size_t opN = 0 ; opN < array_len (rinfo -> dagOps ); opN ++ ) {
478479 RedisModule_Log (
@@ -532,7 +533,7 @@ int RAI_parseDAGLoadArgs(RedisModuleCtx *ctx, RedisModuleString **argv,
532533 RedisModule_CloseKey (key );
533534 char * dictKey = (char * ) RedisModule_Alloc ((strlen (arg_string ) + 5 )* sizeof (char ));
534535 sprintf (dictKey , "%s%04d" , arg_string , 1 );
535- AI_dictAdd (* localContextDict , (void * )dictKey , (void * )t );
536+ AI_dictAdd (* localContextDict , (void * )dictKey , (void * )RAI_TensorGetShallowCopy ( t ) );
536537 AI_dictAdd (* loadedContextDict , (void * )dictKey , (void * )1 );
537538 RedisModule_Free (dictKey );
538539 number_loaded_keys ++ ;
@@ -796,6 +797,7 @@ int RedisAI_DagRunSyntaxParser(RedisModuleCtx *ctx, RedisModuleString **argv,
796797 const char * key = RedisModule_StringPtrLen (currentOp -> inkeys [j ], NULL );
797798 AI_dictEntry * entry = AI_dictFind (mangled_tensors , key );
798799 if (!entry ) {
800+ AI_dictRelease (mangled_tensors );
799801 return RedisModule_ReplyWithError (ctx ,
800802 "ERR INPUT key cannot be found in DAG" );
801803 }
@@ -837,6 +839,8 @@ int RedisAI_DagRunSyntaxParser(RedisModuleCtx *ctx, RedisModuleString **argv,
837839 char * key = (char * )AI_dictGetKey (entry );
838840 AI_dictEntry * mangled_entry = AI_dictFind (mangled_tensors , key );
839841 if (!mangled_entry ) {
842+ AI_dictRelease (mangled_tensors );
843+ AI_dictRelease (mangled_persisted );
840844 return RedisModule_ReplyWithError (ctx ,
841845 "ERR PERSIST key cannot be found in DAG" );
842846 }
@@ -849,6 +853,7 @@ int RedisAI_DagRunSyntaxParser(RedisModuleCtx *ctx, RedisModuleString **argv,
849853 AI_dictReleaseIterator (iter );
850854 }
851855
856+ AI_dictRelease (rinfo -> dagTensorsPersistedContext );
852857 rinfo -> dagTensorsPersistedContext = mangled_persisted ;
853858
854859 {
0 commit comments