Skip to content

Commit

Permalink
[ms-inline asm] Address a potential buffer overflow.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161896 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Chad Rosier committed Aug 14, 2012
1 parent fdbd3c5 commit 5dfc441
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5dfc441

Please sign in to comment.