From 6667bce3d70fd57f642e2b5fea19b553a3e32182 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Fri, 27 Jan 2023 06:01:05 +0000 Subject: [PATCH] Finally fixed the buffer I suppose valgrind, et. al. complaining is a good thing, overall. --- repl/lib_runner.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repl/lib_runner.c b/repl/lib_runner.c index 6ed32a2..32c7350 100644 --- a/repl/lib_runner.c +++ b/repl/lib_runner.c @@ -62,6 +62,7 @@ static int nativeLoadScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu if (!source) { interpreter->errorOutput("Failed to load source file\n"); + Toy_freeLiteral(filePathLiteral); return -1; } @@ -70,6 +71,7 @@ static int nativeLoadScript(Toy_Interpreter* interpreter, Toy_LiteralArray* argu if (!bytecode) { interpreter->errorOutput("Failed to compile source file\n"); + Toy_freeLiteral(filePathLiteral); return -1; } @@ -626,7 +628,9 @@ Toy_Literal Toy_getFilePathLiteral(Toy_Interpreter* interpreter, Toy_Literal* dr Toy_deleteRefString(path); Toy_deleteRefString(drivePath); + Toy_Literal result = TOY_TO_STRING_LITERAL(Toy_createRefStringLength(filePath, realLength)); + TOY_FREE_ARRAY(char, filePath, realLength + 1); - return TOY_TO_STRING_LITERAL(Toy_createRefStringLength(filePath, realLength)); + return result; } \ No newline at end of file