diff --git a/vm/os-genunix.cpp b/vm/os-genunix.cpp index 08893f3889..21b9304e40 100644 --- a/vm/os-genunix.cpp +++ b/vm/os-genunix.cpp @@ -20,8 +20,8 @@ const char* default_image_path() { return "factor.image"; int len = strlen(path); - char* new_path = new char[PATH_MAX + SUFFIX_LEN + 1]; - memcpy(new_path, path, len + 1); + char* new_path = new char[len + SUFFIX_LEN + 1]; + memcpy(new_path, path, len); memcpy(new_path + len, SUFFIX, SUFFIX_LEN + 1); free(const_cast(path)); return new_path;