From: Steve Naroff Date: Thu, 17 Jan 2008 00:36:28 +0000 (+0000) Subject: Declarator::clear(): Null out variable after it's been deleted. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b4a6227f3ee6fca074d0f521757d1ed4f95ef38;p=clang Declarator::clear(): Null out variable after it's been deleted. This avoids a double free (which is good:-) Bug submitted by Eli. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46105 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h index bf7920fa2d..307959f83a 100644 --- a/include/clang/Parse/DeclSpec.h +++ b/include/clang/Parse/DeclSpec.h @@ -566,6 +566,7 @@ public: } DeclTypeInfo.clear(); delete AttrList; + AttrList = 0; } /// mayOmitIdentifier - Return true if the identifier is either optional or diff --git a/test/Sema/declspec.c b/test/Sema/declspec.c index d9e02ec42e..05f492d67a 100644 --- a/test/Sema/declspec.c +++ b/test/Sema/declspec.c @@ -3,3 +3,6 @@ typedef char T[4]; T foo(int n, int m) { } // expected-error {{cannot return array or function}} +void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void); + +