[tracker/tracker-0.10: 64/68] libtracker-sparql-backend: Fix memory leak in Connection.get



commit a5e108a29a089da4be1c47a7d62d4ab106a65db0
Author: Jürg Billeter <j bitron ch>
Date:   Wed Apr 27 13:06:28 2011 +0200

    libtracker-sparql-backend: Fix memory leak in Connection.get
    
    The leak was caused by a bug in valac (fixed in master). This changes
    the code to work correctly with valac versions without the fix as well.
    
    Fixes NB#250455.

 src/libtracker-sparql-backend/tracker-backend.vala |   25 +++++++++----------
 1 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala b/src/libtracker-sparql-backend/tracker-backend.vala
index 76eb956..53f6151 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -198,25 +198,24 @@ class Tracker.Sparql.Backend : Connection {
 		try {
 			// assign to owned variable to ensure it doesn't get freed between check and return
 			var result = singleton;
-			if (result != null) {
-				assert (direct_only == is_direct_only);
-				return result;
-			}
 
-			log_init ();
+			if (result == null) {
+				log_init ();
 
-			direct_only = is_direct_only;
+				direct_only = is_direct_only;
 
-			result = new Tracker.Sparql.Backend ();
+				result = new Tracker.Sparql.Backend ();
 
-			if (cancellable != null && cancellable.is_cancelled ()) {
-				throw new IOError.CANCELLED ("Operation was cancelled");
-			}
+				if (cancellable != null && cancellable.is_cancelled ()) {
+					throw new IOError.CANCELLED ("Operation was cancelled");
+				}
 
-			singleton = result;
-			result.add_weak_pointer ((void**) (&singleton));
+				singleton = result;
+				result.add_weak_pointer ((void**) (&singleton));
+			}
 
-			return singleton;
+			assert (direct_only == is_direct_only);
+			return result;
 		} finally {
 			door.unlock ();
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]