Fix memory leak for rootDirectory variable

The memory for the root directory path is not freed.
This commit is contained in:
André Althaus
2015-06-03 21:48:26 +02:00
parent 33151c64d2
commit 01fe9c3976
2 changed files with 5 additions and 0 deletions

View File

@ -46,6 +46,10 @@ char* readFile(const char* path)
void setRootDirectory(const char* path)
{
if (rootDirectory != NULL)
{
free((void*)rootDirectory);
}
rootDirectory = path;
}

View File

@ -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.