From 83e1ee5084a6c715af8bc87479d7db760afc831b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Wed, 23 Mar 2016 12:17:38 +0100 Subject: [PATCH] VM: fix string copying to not use PATH_MAX here --- vm/os-genunix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;