Remove two small memory leaks on Linux
parent
8a7e9740c9
commit
2bbad8d837
|
@ -30,6 +30,7 @@ const char *default_image_path()
|
||||||
char *new_path = new char[PATH_MAX + SUFFIX_LEN + 1];
|
char *new_path = new char[PATH_MAX + SUFFIX_LEN + 1];
|
||||||
memcpy(new_path,path,len + 1);
|
memcpy(new_path,path,len + 1);
|
||||||
memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1);
|
memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1);
|
||||||
|
free(const_cast<char *>(path));
|
||||||
return new_path;
|
return new_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace factor
|
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()
|
const char *vm_executable_path()
|
||||||
{
|
{
|
||||||
char *path = new char[PATH_MAX + 1];
|
char *path = new char[PATH_MAX + 1];
|
||||||
|
@ -17,7 +17,10 @@ const char *vm_executable_path()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path[size] = '\0';
|
path[size] = '\0';
|
||||||
return safe_strdup(path);
|
|
||||||
|
const char *ret = safe_strdup(path);
|
||||||
|
delete[] path;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue