[cfe-commits] r161896 - /cfe/trunk/lib/Sema/SemaStmt.cpp

Chad Rosier mcrosier at apple.com
Tue Aug 14 14:48:02 PDT 2012


Author: mcrosier
Date: Tue Aug 14 16:48:01 2012
New Revision: 161896

URL: http://llvm.org/viewvc/llvm-project?rev=161896&view=rev
Log:
[ms-inline asm] Address a potential buffer overflow.

Modified:
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161896&r1=161895&r2=161896&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Aug 14 16:48:01 2012
@@ -2870,15 +2870,12 @@
   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;





More information about the cfe-commits mailing list