Skip to content

Commit af351b2

Browse files
committed
Fix leaks
1 parent d001222 commit af351b2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/DAG/dag_builder.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ int RAI_DAGLoadTensor(RAI_DAGRunCtx *run_info, const char *t_name, RAI_Tensor *t
3636
AI_dictAdd(rinfo->tensorsNamesToIndices, (void *)key_name, (void *)instance);
3737
RAI_TensorGetShallowCopy(tensor);
3838
rinfo->dagSharedTensors = array_append(rinfo->dagSharedTensors, (void *)tensor);
39+
RedisModule_FreeString(NULL, key_name);
3940

4041
return REDISMODULE_OK;
4142
}

src/DAG/dag_execute.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ int ValidatePersistKeys(RedisAI_RunInfo *rinfo, AI_dict *tensorsNamesToInd,
1414
AI_dictEntry *entry = AI_dictFind(tensorsNamesToInd, persist_key);
1515
if (!entry) {
1616
RAI_SetError(rinfo->err, RAI_EDAGRUN, "ERR PERSIST key cannot be found in DAG");
17+
AI_dictReleaseIterator(iter);
1718
return REDISMODULE_ERR;
1819
}
1920
}
@@ -52,6 +53,11 @@ int MapTensorsKeysToIndices(RedisAI_RunInfo *rinfo, AI_dict *tensorsNamesToInd)
5253
rinfo->dagSharedTensors = array_append(rinfo->dagSharedTensors, NULL);
5354
}
5455
currentOp->outkeys_indices = array_append(currentOp->outkeys_indices, *ind);
56+
AI_dictEntry *entry = AI_dictFind(tensorsNamesToInd, (void *)key);
57+
// If this key was already in the dict, remove and free the previous index
58+
if (entry) {
59+
RedisModule_Free(AI_dictGetVal(entry));
60+
}
5561
AI_dictReplace(tensorsNamesToInd, (void *)key, (void *)ind);
5662
}
5763
}

0 commit comments

Comments
 (0)