[Orxonox-commit 3617] r8302 - code/trunk/src/orxonox/interfaces

dafrick at orxonox.net dafrick at orxonox.net
Fri Apr 22 19:53:36 CEST 2011


Author: dafrick
Date: 2011-04-22 19:53:36 +0200 (Fri, 22 Apr 2011)
New Revision: 8302

Modified:
   code/trunk/src/orxonox/interfaces/PickupCarrier.cc
Log:
Fixing memory leak in PickupCarrier.


Modified: code/trunk/src/orxonox/interfaces/PickupCarrier.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.cc	2011-04-22 16:42:42 UTC (rev 8301)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.cc	2011-04-22 17:53:36 UTC (rev 8302)
@@ -125,18 +125,22 @@
         if(pickup->isTarget(this)) // If the PickupCarrier itself is a target.
             return this;
 
+        PickupCarrier* target = NULL;
         // Go recursively through all children to check whether they are the target.
         std::vector<PickupCarrier*>* children = this->getCarrierChildren();
         for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
         {
             if(pickup->isTarget(*it))
-                return *it;
+            {
+                target = *it;
+                break;
+            }
         }
 
         children->clear();
         delete children;
 
-        return NULL;
+        return target;
     }
 
     /**




More information about the Orxonox-commit mailing list