Tighten up prototype verification of strchr and strrchr to avoid a crash in the very...
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 30 Sep 2010 11:21:59 +0000 (11:21 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 30 Sep 2010 11:21:59 +0000 (11:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115144 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SimplifyLibCalls.cpp

index 81460bcf4de704eacf2c8b38dbc986e383ebffbe..28aa9e87cd514ed29446868375798183728f62e4 100644 (file)
@@ -223,7 +223,8 @@ struct StrChrOpt : public LibCallOptimization {
     const FunctionType *FT = Callee->getFunctionType();
     if (FT->getNumParams() != 2 ||
         FT->getReturnType() != Type::getInt8PtrTy(*Context) ||
-        FT->getParamType(0) != FT->getReturnType())
+        FT->getParamType(0) != FT->getReturnType() ||
+        !FT->getParamType(1)->isIntegerTy(32))
       return 0;
 
     Value *SrcStr = CI->getArgOperand(0);
@@ -273,7 +274,8 @@ struct StrRChrOpt : public LibCallOptimization {
     const FunctionType *FT = Callee->getFunctionType();
     if (FT->getNumParams() != 2 ||
         FT->getReturnType() != Type::getInt8PtrTy(*Context) ||
-        FT->getParamType(0) != FT->getReturnType())
+        FT->getParamType(0) != FT->getReturnType() ||
+        !FT->getParamType(1)->isIntegerTy(32))
       return 0;
 
     Value *SrcStr = CI->getArgOperand(0);