[Bf-blender-cvs] [8742dedaabb] greasepencil-object: GPencil: Fix possible memory leak in function

Antonioya noreply at git.blender.org
Tue Jul 9 22:44:48 CEST 2019


Commit: 8742dedaabb103803837348c4a46a4e6fcd243bb
Author: Antonioya
Date:   Tue Jul 9 22:44:26 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rB8742dedaabb103803837348c4a46a4e6fcd243bb

GPencil: Fix possible memory leak in function

The function exit before the END_ITER

===================================================================

M	source/blender/blenkernel/intern/gpencil.c

===================================================================

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index cbc21c90146..99f9419de9f 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2120,16 +2120,17 @@ static void gpencil_add_new_points(bGPDstroke *gps, float *coord_array, int init
 /* Helper function to get the first collection that includes the object */
 static Collection *gpencil_get_parent_collection(Scene *scene, Object *ob)
 {
+  Collection *mycol = NULL;
   FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {
     for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
-      if (cob->ob == ob) {
-        return collection;
+      if ((mycol == NULL) && (cob->ob == ob)) {
+        mycol = collection;
       }
     }
   }
   FOREACH_SCENE_COLLECTION_END;
 
-  return NULL;
+  return mycol;
 }
 
 /* Convert a curve to grease pencil stroke.



More information about the Bf-blender-cvs mailing list