mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Fix memory leak for rootDirectory variable
The memory for the root directory path is not freed.
This commit is contained in:
@ -46,6 +46,10 @@ char* readFile(const char* path)
|
||||
|
||||
void setRootDirectory(const char* path)
|
||||
{
|
||||
if (rootDirectory != NULL)
|
||||
{
|
||||
free((void*)rootDirectory);
|
||||
}
|
||||
rootDirectory = path;
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ void runFile(WrenBindForeignMethodFn bindForeign, const char* path)
|
||||
|
||||
wrenFreeVM(vm);
|
||||
free(source);
|
||||
setRootDirectory(NULL);
|
||||
|
||||
// Exit with an error code if the script failed.
|
||||
if (result == WREN_RESULT_COMPILE_ERROR) exit(65); // EX_DATAERR.
|
||||
|
||||
Reference in New Issue
Block a user