Replace strcpy with memcpy when we have the length around anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2010-01-28 18:04:38 +00:00
parent 2c47368a7d
commit 12ea66a727
5 changed files with 14 additions and 14 deletions

View File

@ -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;