]> gitweb.factorcode.org Git - factor.git/commitdiff
Remove two small memory leaks on Linux
authorSamuel Tardieu <sam@rfc1149.net>
Sat, 3 Oct 2009 16:17:55 +0000 (18:17 +0200)
committerSamuel Tardieu <sam@rfc1149.net>
Sat, 3 Oct 2009 16:18:07 +0000 (18:18 +0200)
vm/os-genunix.cpp
vm/os-linux.cpp

index 7bbe388ff28de081e7f9da52950454e2f4172e9d..065f0dfd4094174d49603976bedac5ad43359fdc 100644 (file)
@@ -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;
 }
 
index 2d26fba39051744dce1ec00f854f55897bddd9b9..352467d37962a92bcbc6941768e0b383f4ea29c5 100644 (file)
@@ -3,7 +3,7 @@
 namespace factor
 {
 
-/* Snarfed from SBCL linux-so.c. You must delete[] the result yourself. */
+/* 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';
-               return safe_strdup(path);
+
+               const char *ret = safe_strdup(path);
+               delete[] path;
+               return ret;
        }
 }