[epiphany] ephy-history-service: fix a few leaks



commit c514bd1ee01d6982424e4d5eefb545fc5254a59b
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Sep 6 13:07:44 2012 +0300

    ephy-history-service: fix a few leaks
    
    If there is an error processing the statement, then unref it before
    returning.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683475

 lib/history/ephy-history-service-hosts-table.c  |    5 ++++-
 lib/history/ephy-history-service-urls-table.c   |    2 ++
 lib/history/ephy-history-service-visits-table.c |    1 +
 3 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c
index fab7294..04be063 100644
--- a/lib/history/ephy-history-service-hosts-table.c
+++ b/lib/history/ephy-history-service-hosts-table.c
@@ -77,6 +77,7 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho
       ephy_sqlite_statement_bind_double (statement, 3, host->zoom_level, &error) == FALSE) {
     g_error ("Could not insert host into hosts table: %s", error->message);
     g_error_free (error);
+    g_object_unref (statement);
     return;
   }
 
@@ -84,7 +85,6 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho
   if (error) {
     g_error ("Could not insert host into hosts table: %s", error->message);
     g_error_free (error);
-    return;
   } else {
     host->id = ephy_sqlite_connection_get_last_insert_id (priv->history_database);
   }
@@ -118,6 +118,7 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost
       ephy_sqlite_statement_bind_int (statement, 4, host->id, &error) == FALSE) {
     g_error ("Could not modify host in hosts table: %s", error->message);
     g_error_free (error);
+    g_object_unref (statement);
     return;
   }
 
@@ -173,6 +174,8 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s
   }
 
   if (ephy_sqlite_statement_step (statement, &error) == FALSE) {
+    if (error)
+      g_error_free (error);
     g_object_unref (statement);
     return NULL;
   }
diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c
index fa1539b..f0d4451 100644
--- a/lib/history/ephy-history-service-urls-table.c
+++ b/lib/history/ephy-history-service-urls-table.c
@@ -151,6 +151,7 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url)
       ephy_sqlite_statement_bind_int (statement, 5, url->host->id, &error) == FALSE) {
     g_error ("Could not insert URL into urls table: %s", error->message);
     g_error_free (error);
+    g_object_unref (statement);
     return;
   }
 
@@ -193,6 +194,7 @@ ephy_history_service_update_url_row (EphyHistoryService *self, EphyHistoryURL *u
       ephy_sqlite_statement_bind_int (statement, 6, url->id, &error) == FALSE) {
     g_error ("Could not modify URL in urls table: %s", error->message);
     g_error_free (error);
+    g_object_unref (statement);
     return;
   }
 
diff --git a/lib/history/ephy-history-service-visits-table.c b/lib/history/ephy-history-service-visits-table.c
index b09c664..0beaa23 100644
--- a/lib/history/ephy-history-service-visits-table.c
+++ b/lib/history/ephy-history-service-visits-table.c
@@ -72,6 +72,7 @@ ephy_history_service_add_visit_row (EphyHistoryService *self, EphyHistoryPageVis
       ephy_sqlite_statement_bind_int (statement, 2, visit->visit_type, &error) == FALSE ) {
     g_error ("Could not build visits table addition statement: %s", error->message);
     g_error_free (error);
+    g_object_unref (statement);
     return;
   }
 



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