summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-02-07 03:15:01 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-02-07 03:15:01 +0000
commit0df91b2c8677f3f8fd25b46953051c9d95c1c1ae (patch)
treeaf972041655a3538e8e37457c048ae1773f7df7b /tools
parent92570c4a1a11cbdaf5ffb13547428dbee1103875 (diff)
downloadllvm-0df91b2c8677f3f8fd25b46953051c9d95c1c1ae.tar.gz
llvm-0df91b2c8677f3f8fd25b46953051c9d95c1c1ae.tar.bz2
llvm-0df91b2c8677f3f8fd25b46953051c9d95c1c1ae.tar.xz
Free the buffer in the case where we don't create a module out of it, as
pointed out by Torok Edwin. Remove trailing whitespaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/gold/gold-plugin.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 69fb0ea641..a974d81d32 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -161,7 +161,7 @@ ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
// Gold has found what might be IR part-way inside of a file, such as
// an .a archive.
if (lseek(file->fd, file->offset, SEEK_SET) == -1) {
- (*message)(LDPL_ERROR,
+ (*message)(LDPL_ERROR,
"Failed to seek to archive member of %s at offset %d: %s\n",
file->name,
file->offset, strerror(errno));
@@ -169,21 +169,24 @@ ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
}
buf = malloc(file->filesize);
if (!buf) {
- (*message)(LDPL_ERROR,
+ (*message)(LDPL_ERROR,
"Failed to allocate buffer for archive member of size: %d\n",
file->filesize);
return LDPS_ERR;
}
if (read(file->fd, buf, file->filesize) != file->filesize) {
- (*message)(LDPL_ERROR,
- "Failed to read archive member of %s at offset %d: %s\n",
+ (*message)(LDPL_ERROR,
+ "Failed to read archive member of %s at offset %d: %s\n",
file->name,
- file->offset,
+ file->offset,
strerror(errno));
+ free(buf);
return LDPS_ERR;
}
- if (!lto_module_is_object_file_in_memory(buf, file->filesize))
+ if (!lto_module_is_object_file_in_memory(buf, file->filesize)) {
+ free(buf);
return LDPS_OK;
+ }
} else if (!lto_module_is_object_file(file->name))
return LDPS_OK;