diff options
Diffstat (limited to 'tools/llvm-ld')
-rw-r--r-- | tools/llvm-ld/llvm-ld.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index e71aefc0ce..118f6b720c 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -179,8 +179,9 @@ static char ** CopyEnv(char ** const envp) { // Make a copy of the list. Don't forget the NULL that ends the list. entries = 0; while (envp[entries] != NULL) { - newenv[entries] = new char[strlen (envp[entries]) + 1]; - strcpy (newenv[entries], envp[entries]); + size_t len = strlen(envp[entries]) + 1; + newenv[entries] = new char[len]; + memcpy(newenv[entries], envp[entries], len); ++entries; } newenv[entries] = NULL; |