don't use strtoul on a non-null-terminated string.

llvm-svn: 66732
This commit is contained in:
Chris Lattner 2009-03-11 22:52:17 +00:00
parent 294943c99b
commit 99d892b892
1 changed files with 5 additions and 4 deletions

View File

@ -274,9 +274,11 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
if (isdigit(EscapedChar)) {
// %n - Assembler operand n
char *End;
unsigned long N = strtoul(CurPtr-1, &End, 10);
assert(End != CurPtr-1 && "We know that EscapedChar is a digit!");
unsigned N = 0;
--CurPtr;
while (CurPtr != StrEnd && isdigit(*CurPtr))
N = N*10+((*CurPtr++)-'0');
unsigned NumOperands =
getNumOutputs() + getNumPlusOperands() + getNumInputs();
@ -285,7 +287,6 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
return diag::err_asm_invalid_operand_number;
}
CurPtr = End;
Pieces.push_back(AsmStringPiece(N, Modifier));
continue;
}