summaryrefslogtreecommitdiff
path: root/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
commit1db1c239fe1654f174fbddd70e104909d2ad5f5c (patch)
tree645d614f0e81fa19f18c1d204f8e9ccffe4dba75 /lib
parenta8f5cd3539580b2fe3c20c748c1374f76992f113 (diff)
downloadllvm-1db1c239fe1654f174fbddd70e104909d2ad5f5c.tar.gz
llvm-1db1c239fe1654f174fbddd70e104909d2ad5f5c.tar.bz2
llvm-1db1c239fe1654f174fbddd70e104909d2ad5f5c.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145106 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/MemoryBuiltins.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp
index 8d451c46f9..b145650b0f 100644
--- a/lib/Analysis/MemoryBuiltins.cpp
+++ b/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