From 7927aed5d60e494c9072087bf5451617d49d6b49 Mon Sep 17 00:00:00 2001
From: Robert Bragg <robert@linux.intel.com>
Date: Tue, 26 Oct 2010 17:38:58 +0100
Subject: [PATCH] cogl-object: correctly free user_data_array in _unref

If there is private data associated with a CoglObject then there may be
a user_data_array that needs to be freed. The code was mistakenly
freeing the array inside the loop that was actually iterating over the
user data array notifying the objects destruction instead of waiting
until all the data entries had been destroyed.
---
 cogl/cogl-object.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cogl/cogl-object.c b/cogl/cogl-object.c
index aa11cef2c..7a5472ce3 100644
--- a/cogl/cogl-object.c
+++ b/cogl/cogl-object.c
@@ -86,9 +86,8 @@ cogl_object_unref (void *object)
                   if (entry->destroy)
                     entry->destroy (entry->user_data);
                 }
+              g_array_free (obj->user_data_array, TRUE);
             }
-
-          g_array_free (obj->user_data_array, TRUE);
         }
 
       COGL_OBJECT_DEBUG_FREE (obj);