From 70ca27486e7fbf8dcf6a0ffc3a665133935f4751 Mon Sep 17 00:00:00 2001 From: Ratstail91 Date: Tue, 28 Feb 2023 17:37:43 +1100 Subject: [PATCH] Bugfix a leak? --- source/toy_interpreter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/toy_interpreter.c b/source/toy_interpreter.c index 49664cc..c25f367 100644 --- a/source/toy_interpreter.c +++ b/source/toy_interpreter.c @@ -1767,8 +1767,9 @@ static bool execIndexAssign(Toy_Interpreter* interpreter) { assign = Toy_popLiteralArray(&interpreter->stack); } else { - compound = result; //no free - + compound = result; + Toy_freeLiteral(result); + //suppress the extra assign value Toy_Literal tmp = Toy_popLiteralArray(&interpreter->stack); Toy_freeLiteral(tmp); @@ -1780,6 +1781,10 @@ static bool execIndexAssign(Toy_Interpreter* interpreter) { compound = Toy_popLiteralArray(&interpreter->stack); if (TOY_IS_IDENTIFIER(compound)) { + if (freeIdn) { + Toy_freeLiteral(compoundIdn); + } + compoundIdn = compound; Toy_parseIdentifierToValue(interpreter, &compound); freeIdn = true;