Check length of string before we walk off the end of it.

Thanks, Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-04-16 20:31:06 +00:00
parent 0ed8df38c2
commit 43e607303b

View File

@ -2823,9 +2823,9 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
// Check for call to invalid intrinsic to avoid crashing later.
if (Function *theF = dyn_cast<Function>(V)) {
if (theF->hasName() &&
0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5) &&
!theF->getIntrinsicID(true))
if (theF->hasName() && (strlen(theF->getValueName()->getKeyData()) >= 5)&&
(0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
!theF->getIntrinsicID(true))
GEN_ERROR("Call to invalid LLVM intrinsic function '" +
theF->getName() + "'");
}