From ab56f36bfbc7d9de811110cdfa5e2f0c324fbbbb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Feb 2019 11:48:41 +0100 Subject: [PATCH] LibC: strdup() forgot to allocate space for the null character. --- LibC/string.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibC/string.cpp b/LibC/string.cpp index 79d425dc4f..02d8d934ea 100644 --- a/LibC/string.cpp +++ b/LibC/string.cpp @@ -55,7 +55,7 @@ size_t strlen(const char* str) char* strdup(const char* str) { size_t len = strlen(str); - char* new_str = (char*)malloc(len); + char* new_str = (char*)malloc(len + 1); strcpy(new_str, str); return new_str; }