aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-01-28 18:04:38 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-01-28 18:04:38 +0000
commit12ea66a7277240c5b045ed14c140f94d453eea0e (patch)
tree86b0fb053e20cd76aab065b69b25eee033939677 /tools
parent2c47368a7d843486a59e12a08595297003e3cb2d (diff)
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
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/ExtractFunction.cpp8
-rw-r--r--tools/llvm-ld/llvm-ld.cpp5
2 files changed, 5 insertions, 8 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 918d6a6a2a..70011a798b 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -323,8 +323,6 @@ llvm::SplitFunctionsOutOfModule(Module *M,
Module *BugDriver::ExtractMappedBlocksFromModule(const
std::vector<BasicBlock*> &BBs,
Module *M) {
- char *ExtraArg = NULL;
-
sys::Path uniqueFilename(OutputPrefix + "-extractblocks");
std::string ErrMsg;
if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
@@ -359,9 +357,8 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
}
BlocksToNotExtractFile.close();
- const char *uniqueFN = uniqueFilename.c_str();
- ExtraArg = (char*)malloc(23 + strlen(uniqueFN));
- strcat(strcpy(ExtraArg, "--extract-blocks-file="), uniqueFN);
+ std::string uniqueFN = "--extract-blocks-file=" + uniqueFilename.str();
+ const char *ExtraArg = uniqueFN.c_str();
std::vector<const PassInfo*> PI;
std::vector<BasicBlock *> EmptyBBs; // This parameter is ignored.
@@ -370,7 +367,6 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
if (uniqueFilename.exists())
uniqueFilename.eraseFromDisk(); // Free disk space
- free(ExtraArg);
if (Ret == 0) {
outs() << "*** Basic Block extraction failed, please report a bug!\n";
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;