[cfe-commits] r48411 - /cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Chris Lattner sabre at nondot.org
Sat Mar 15 18:25:17 PDT 2008


Author: lattner
Date: Sat Mar 15 20:25:17 2008
New Revision: 48411

URL: http://llvm.org/viewvc/llvm-project?rev=48411&view=rev
Log:
fix a crasher where an invalid program that multiply defined
a protocol could smash more references in than are allocated.

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=48411&r1=48410&r2=48411&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Mar 15 20:25:17 2008
@@ -202,17 +202,19 @@
   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;
   }
   





More information about the cfe-commits mailing list