From: Douglas Gregor Date: Wed, 4 Apr 2012 00:34:49 +0000 (+0000) Subject: Eliminate obvious use-after-free. Fixes PR12433 / . X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0d06e2e6b340c198892fa0389fde906903a47ec;p=clang Eliminate obvious use-after-free. Fixes PR12433 / . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153982 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 9436bfb50b..840fa13282 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3898,9 +3898,9 @@ QualType ASTReader::readTypeRecord(unsigned Index) { ExceptionSpecificationType EST = static_cast(Record[Idx++]); EPI.ExceptionSpecType = EST; + SmallVector Exceptions; if (EST == EST_Dynamic) { EPI.NumExceptions = Record[Idx++]; - SmallVector Exceptions; for (unsigned I = 0; I != EPI.NumExceptions; ++I) Exceptions.push_back(readType(*Loc.F, Record, Idx)); EPI.Exceptions = Exceptions.data(); diff --git a/test/PCH/cxx-functions.cpp b/test/PCH/cxx-functions.cpp new file mode 100644 index 0000000000..74df01a094 --- /dev/null +++ b/test/PCH/cxx-functions.cpp @@ -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(); +} diff --git a/test/PCH/cxx-functions.h b/test/PCH/cxx-functions.h new file mode 100644 index 0000000000..8aa49869a9 --- /dev/null +++ b/test/PCH/cxx-functions.h @@ -0,0 +1 @@ +void foo() throw( int, short, char, float, double );