aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Stmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-11 22:52:17 +0000
committerChris Lattner <sabre@nondot.org>2009-03-11 22:52:17 +0000
commitcafc222b2a411d4c1680a9be66ae922deb7799d2 (patch)
tree132a912bfbfbc77f0e85a159488620b22a7ecfdd /lib/AST/Stmt.cpp
parente06a75f4c8ea30b6a99d5aa1dce5feda64da09c6 (diff)
don't use strtoul on a non-null-terminated string.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Stmt.cpp')
-rw-r--r--lib/AST/Stmt.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index cc120a684c..f68ed0ac89 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -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;
}