From 4339f7d78fd3077e6f0a42eebbf6ba040c19e6c4 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 16 Apr 2007 20:31:06 +0000 Subject: [PATCH] Check length of string before we walk off the end of it. Thanks, Chris. llvm-svn: 36155 --- llvm/lib/AsmParser/llvmAsmParser.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index 55440085426e..263ef4c6eccb 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -2823,9 +2823,9 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { // Check for call to invalid intrinsic to avoid crashing later. if (Function *theF = dyn_cast(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() + "'"); }