[cfe-commits] r66732 - /cfe/trunk/lib/AST/Stmt.cpp
Chris Lattner
sabre at nondot.org
Wed Mar 11 15:52:18 PDT 2009
Author: lattner
Date: Wed Mar 11 17:52:17 2009
New Revision: 66732
URL: http://llvm.org/viewvc/llvm-project?rev=66732&view=rev
Log:
don't use strtoul on a non-null-terminated string.
Modified:
cfe/trunk/lib/AST/Stmt.cpp
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=66732&r1=66731&r2=66732&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Wed Mar 11 17:52:17 2009
@@ -274,9 +274,11 @@
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 @@
return diag::err_asm_invalid_operand_number;
}
- CurPtr = End;
Pieces.push_back(AsmStringPiece(N, Modifier));
continue;
}
More information about the cfe-commits
mailing list