diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-16 01:25:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-16 01:25:17 +0000 |
commit | 5074f8f3ef932e502ec99b6015482002f2d34936 (patch) | |
tree | f114b53a676f602f38692af4d9d35f6a713d24b1 | |
parent | f87ca0a7d13e33c0e9e5bf0ac64d1392e3c2c0aa (diff) | |
download | bcm5719-llvm-5074f8f3ef932e502ec99b6015482002f2d34936.tar.gz bcm5719-llvm-5074f8f3ef932e502ec99b6015482002f2d34936.zip |
fix a crasher where an invalid program that multiply defined
a protocol could smash more references in than are allocated.
llvm-svn: 48411
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index af57d09ce62..3b8baea519f 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/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; } |