summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-29 21:52:46 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-29 21:52:46 +0000
commit7a1e775a7e6c3c7c7c283253dd8be39ff7c6da92 (patch)
treeada65930ad565a7029ec1c254e418b8f5c9d21ac /llvm/include
parent836b1aed05c5d909fb399e8de9a299f4c5bed1d6 (diff)
downloadbcm5719-llvm-7a1e775a7e6c3c7c7c283253dd8be39ff7c6da92.tar.gz
bcm5719-llvm-7a1e775a7e6c3c7c7c283253dd8be39ff7c6da92.zip
PR19553: Memory leak in RuntimeDyldELF::createObjectImageFromFile
This starts in MCJIT::getSymbolAddress where the unique_ptr<object::Binary> is release()d and (after a cast) passed to a single caller, MCJIT::addObjectFile. addObjectFile calls RuntimeDyld::loadObject. RuntimeDld::loadObject calls RuntimeDyldELF::createObjectFromFile And the pointer is never owned at this point. I say this point, because the alternative codepath, RuntimeDyldMachO::createObjectFile certainly does take ownership, so this seemed like a good hint that this was a/the right place to take ownership. llvm-svn: 207580
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ExecutionEngine/ExecutionEngine.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/RuntimeDyld.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
index 70440d725d1..07a04154cd2 100644
--- a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -222,7 +222,7 @@ public:
/// needed by another object.
///
/// MCJIT will take ownership of the ObjectFile.
- virtual void addObjectFile(object::ObjectFile *O) {
+ virtual void addObjectFile(std::unique_ptr<object::ObjectFile> O) {
llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
}
diff --git a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h
index 8d7b81bb6e2..30c0d49ade0 100644
--- a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h
+++ b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h
@@ -55,7 +55,7 @@ public:
/// Ownership of the input object is transferred to the ObjectImage
/// instance returned from this function if successful. In the case of load
/// failure, the input object will be deleted.
- ObjectImage *loadObject(object::ObjectFile *InputObject);
+ ObjectImage *loadObject(std::unique_ptr<object::ObjectFile> InputObject);
/// Get the address of our local copy of the symbol. This may or may not
/// be the address used for relocation (clients can copy the data around
OpenPOWER on IntegriCloud