Paste: Sam
Author: | Memory leaks removal |
Mode: | patch |
Date: | Sat, 3 Oct 2009 16:07:40 |
Plain Text |
diff --git a/vm/os-genunix.cpp b/vm/os-genunix.cpp
index 7bbe388..065f0df 100644
+++ b/vm/os-genunix.cpp
@@ -30,6 +30,7 @@ const char *default_image_path()
char *new_path = new char[PATH_MAX + SUFFIX_LEN + 1];
memcpy(new_path,path,len + 1);
memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1);
+ free(const_cast<char *>(path));
return new_path;
}
diff --git a/vm/os-linux.cpp b/vm/os-linux.cpp
index 2d26fba..352467d 100644
+++ b/vm/os-linux.cpp
@@ -3,7 +3,7 @@
namespace factor
{
+/* Snarfed from SBCL linux-so.c. You must free() the result yourself. */
const char *vm_executable_path()
{
char *path = new char[PATH_MAX + 1];
@@ -17,7 +17,10 @@ const char *vm_executable_path()
else
{
path[size] = '\0';
+
+ const char *ret = safe_strdup(path);
+ delete[] path;
+ return ret;
}
}
New Annotation