[tracker/tracker-0.10] libtracker-sparql-backend: Fix memory leak in Connection.get
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.10] libtracker-sparql-backend: Fix memory leak in Connection.get
- Date: Thu, 28 Apr 2011 11:11:42 +0000 (UTC)
commit adc9861bf374d91ecb1b90b5bffd94fc86cf2e0f
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]