aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-08-14 21:48:01 +0000
committerChad Rosier <mcrosier@apple.com>2012-08-14 21:48:01 +0000
commit5dfc44131128abc354fb6936caed01b71c83be70 (patch)
tree1a32e836df181b9397e169ffe703acbdf2fe14cb
parentfdbd3c5705a7183809c5f49d1e50fbfd93641ceb (diff)
[ms-inline asm] Address a potential buffer overflow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161896 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaStmt.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 89f68e3237..febcdc9441 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -2870,15 +2870,12 @@ static std::string buildMSAsmString(Sema &SemaRef,
TokenBuf.resize(512);
unsigned AsmLineNum = 0;
for (unsigned i = 0, e = AsmToks.size(); i < e; ++i) {
- const char *ThisTokBuf = &TokenBuf[0];
bool StringInvalid = false;
- unsigned ThisTokLen =
- Lexer::getSpelling(AsmToks[i], ThisTokBuf, SemaRef.getSourceManager(),
- SemaRef.getLangOpts(), &StringInvalid);
if (i && (!AsmLineNum || i != LineEnds[AsmLineNum-1]) &&
needSpaceAsmToken(AsmToks[i]))
Asm += ' ';
- Asm += StringRef(ThisTokBuf, ThisTokLen);
+ Asm += SemaRef.PP.getSpelling(AsmToks[i], TokenBuf, &StringInvalid);
+ assert (!StringInvalid && "Expected valid string!");
if (i + 1 == LineEnds[AsmLineNum] && i + 1 != AsmToks.size()) {
Asm += '\n';
++AsmLineNum;