[PATCH setup] Fix an allocation length error

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH setup] Fix an allocation length error

Jon TURNEY
Allow for the terminating null.
---
 archive.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/archive.cc b/archive.cc
index e4af4f7..1ceb355 100644
--- a/archive.cc
+++ b/archive.cc
@@ -173,7 +173,7 @@ archive::extract_file (archive * source, const std::string& prefixURL,
   break;
  case ARCHIVE_FILE_DIRECTORY:
   {
-    char *path = (char *) alloca (destfilename.size());
+    char *path = (char *) alloca (destfilename.size() + 1);
     strcpy (path, destfilename.c_str());
     while (path[0] && path[strlen (path) - 1] == '/')
       path[strlen (path) - 1] = 0;
--
2.21.0