Fix memory issues
This commit is contained in:
@@ -95,7 +95,7 @@ void addVariable(GroundVariable **head, const char *id, GroundValue data) {
|
||||
}
|
||||
GroundVariable* item = malloc(sizeof(GroundVariable));
|
||||
snprintf(item->id, MAX_ID_LEN, "%s", id);
|
||||
item->value = data;
|
||||
item->value = copyGroundValue(&data);
|
||||
HASH_ADD_STR(*head, id, item);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ void interpretGroundInstruction(GroundInstruction inst, GroundScope* scope) {
|
||||
GroundVariable* variable = findVariable(*scope->variables, in->args.args[i].value.refName);
|
||||
if (variable) {
|
||||
free(in->args.args[i].value.refName); // Free the strdup'd refName
|
||||
in->args.args[i].value.value = variable->value;
|
||||
in->args.args[i].value.value = copyGroundValue(&variable->value);
|
||||
in->args.args[i].type = VALUE;
|
||||
} else {
|
||||
runtimeError(UNKNOWN_VARIABLE, NULL, in, currentInstruction);
|
||||
|
||||
Reference in New Issue
Block a user