summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-11-23 17:58:47 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-11-23 17:58:47 +0000
commit6e013bf96c295acfe5da99ded7686488a496d376 (patch)
tree313b22e3963f597a666eed1fb697803b8c244a57 /llvm/lib
parent81a2af12d61d8de39b20e647d637e4338d7e7cc5 (diff)
downloadbcm5719-llvm-6e013bf96c295acfe5da99ded7686488a496d376.tar.gz
bcm5719-llvm-6e013bf96c295acfe5da99ded7686488a496d376.zip
Validate the return type when checking if a function is malloc.
Fixes PR11426. Not sure if a test case with a "wrong" malloc would be useful. llvm-svn: 145106
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/MemoryBuiltins.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 8d451c46f9b..b145650b0f0 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -48,10 +48,10 @@ static bool isMallocCall(const CallInst *CI) {
// FIXME: workaround for PR5130, this will be obsolete when a nobuiltin
// attribute will exist.
FunctionType *FTy = Callee->getFunctionType();
- if (FTy->getNumParams() != 1)
- return false;
- return FTy->getParamType(0)->isIntegerTy(32) ||
- FTy->getParamType(0)->isIntegerTy(64);
+ return FTy->getReturnType() == Type::getInt8PtrTy(FTy->getContext()) &&
+ FTy->getNumParams() == 1 &&
+ (FTy->getParamType(0)->isIntegerTy(32) ||
+ FTy->getParamType(0)->isIntegerTy(64));
}
/// extractMallocCall - Returns the corresponding CallInst if the instruction
OpenPOWER on IntegriCloud