r260814 - Fix use after free.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 13 05:42:43 PST 2016


Author: d0k
Date: Sat Feb 13 07:42:41 2016
New Revision: 260814

URL: http://llvm.org/viewvc/llvm-project?rev=260814&view=rev
Log:
Fix use after free.

Found by asan.

Modified:
    cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=260814&r1=260813&r2=260814&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Sat Feb 13 07:42:41 2016
@@ -1026,7 +1026,7 @@ public:
 
     diag::Flavor Flavor = WarningName[1] == 'W' ? diag::Flavor::WarningOrError
                                                 : diag::Flavor::Remark;
-    StringRef Group = WarningName.substr(2);
+    StringRef Group = StringRef(WarningName).substr(2);
     bool unknownDiag = false;
     if (Group == "everything") {
       // Special handling for pragma clang diagnostic ... "-Weverything".




More information about the cfe-commits mailing list