aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-16 01:25:17 +0000
committerChris Lattner <sabre@nondot.org>2008-03-16 01:25:17 +0000
commit439e71f4be0148101281f72f10c9f8bf743e78bd (patch)
treeeb29640cc120e9dd33219a2c2c64a323d670f8e7 /lib/Sema/SemaDeclObjC.cpp
parentcca59d77c4b84fd2da268018dbaf9431a621e75b (diff)
fix a crasher where an invalid program that multiply defined
a protocol could smash more references in than are allocated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48411 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--lib/Sema/SemaDeclObjC.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index af57d09ce6..3b8baea519 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -202,17 +202,19 @@ Sema::DeclTy *Sema::ActOnStartProtocolInterface(
ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolName];
if (PDecl) {
// Protocol already seen. Better be a forward protocol declaration
- if (!PDecl->isForwardDecl())
+ if (!PDecl->isForwardDecl()) {
Diag(ProtocolLoc, diag::err_duplicate_protocol_def,
ProtocolName->getName());
- else {
- PDecl->setForwardDecl(false);
- PDecl->AllocReferencedProtocols(NumProtoRefs);
+ // Just return the protocol we already had.
+ // FIXME: don't leak the objects passed in!
+ return PDecl;
}
- }
- else {
+
+ PDecl->setForwardDecl(false);
+ PDecl->AllocReferencedProtocols(NumProtoRefs);
+ } else {
PDecl = ObjCProtocolDecl::Create(Context, AtProtoInterfaceLoc, NumProtoRefs,
- ProtocolName);
+ ProtocolName, false);
ObjCProtocols[ProtocolName] = PDecl;
}