[cfe-commits] r153982 - in /cfe/trunk: lib/Serialization/ASTReader.cpp test/PCH/cxx-functions.cpp test/PCH/cxx-functions.h

Douglas Gregor dgregor at apple.com
Tue Apr 3 17:34:49 PDT 2012


Author: dgregor
Date: Tue Apr  3 19:34:49 2012
New Revision: 153982

URL: http://llvm.org/viewvc/llvm-project?rev=153982&view=rev
Log:
Eliminate obvious use-after-free. Fixes PR12433 / <rdar://problem/11168333>.

Added:
    cfe/trunk/test/PCH/cxx-functions.cpp   (with props)
    cfe/trunk/test/PCH/cxx-functions.h   (with props)
Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=153982&r1=153981&r2=153982&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Apr  3 19:34:49 2012
@@ -3898,9 +3898,9 @@
     ExceptionSpecificationType EST =
         static_cast<ExceptionSpecificationType>(Record[Idx++]);
     EPI.ExceptionSpecType = EST;
+    SmallVector<QualType, 2> Exceptions;
     if (EST == EST_Dynamic) {
       EPI.NumExceptions = Record[Idx++];
-      SmallVector<QualType, 2> Exceptions;
       for (unsigned I = 0; I != EPI.NumExceptions; ++I)
         Exceptions.push_back(readType(*Loc.F, Record, Idx));
       EPI.Exceptions = Exceptions.data();

Added: cfe/trunk/test/PCH/cxx-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-functions.cpp?rev=153982&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-functions.cpp (added)
+++ cfe/trunk/test/PCH/cxx-functions.cpp Tue Apr  3 19:34:49 2012
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-functions.h -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-functions.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+
+void test_foo() {
+  foo();
+}

Propchange: cfe/trunk/test/PCH/cxx-functions.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/PCH/cxx-functions.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/PCH/cxx-functions.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cfe/trunk/test/PCH/cxx-functions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-functions.h?rev=153982&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-functions.h (added)
+++ cfe/trunk/test/PCH/cxx-functions.h Tue Apr  3 19:34:49 2012
@@ -0,0 +1 @@
+void foo() throw( int, short, char, float, double );

Propchange: cfe/trunk/test/PCH/cxx-functions.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/PCH/cxx-functions.h
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/PCH/cxx-functions.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list