r20004 - gnucash/trunk/src/backend - Plug more memory leaks

Phil Longstaff plongstaff at code.gnucash.org
Thu Dec 30 10:54:07 EST 2010


Author: plongstaff
Date: 2010-12-30 10:54:06 -0500 (Thu, 30 Dec 2010)
New Revision: 20004
Trac: http://svn.gnucash.org/trac/changeset/20004

Modified:
   gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
   gnucash/trunk/src/backend/sql/gnc-account-sql.c
Log:
Plug more memory leaks


Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2010-12-30 15:53:07 UTC (rev 20003)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2010-12-30 15:54:06 UTC (rev 20004)
@@ -620,16 +620,16 @@
         PWARN("No lock table in database, so not unlocking it.");
         return;
     }
+    dbi_result_free( result );
 
-    if ( ( result = dbi_conn_query( dcon, "BEGIN" )) )
+    result = dbi_conn_query( dcon, "BEGIN" );
+    if ( result )
     {
         /* Delete the entry if it's our hostname and PID */
         gchar hostname[ GNC_HOST_NAME_MAX + 1 ];
-        if (result)
-        {
-            dbi_result_free( result );
-            result = NULL;
-        }
+
+        dbi_result_free( result );
+        result = NULL;
         memset( hostname, 0, sizeof(hostname) );
         gethostname( hostname, GNC_HOST_NAME_MAX );
         result = dbi_conn_queryf( dcon, "SELECT * FROM %s WHERE Hostname = '%s' AND PID = '%d'", lock_table, hostname, (int)GETPID() );
@@ -653,7 +653,7 @@
                 }
                 return;
             }
-            if (result)
+            else
             {
                 dbi_result_free( result );
                 result = NULL;

Modified: gnucash/trunk/src/backend/sql/gnc-account-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-account-sql.c	2010-12-30 15:53:07 UTC (rev 20003)
+++ gnucash/trunk/src/backend/sql/gnc-account-sql.c	2010-12-30 15:54:06 UTC (rev 20004)
@@ -264,6 +264,7 @@
                         gnc_account_append_child( pParent, s->pAccount );
                         next_elem = g_list_next( elem );
                         l_accounts_needing_parents = g_list_delete_link( l_accounts_needing_parents, elem );
+                        g_free( s );
                         elem = next_elem;
                         progress_made = TRUE;
                     }
@@ -285,6 +286,7 @@
                 {
                     gnc_account_append_child( root, s->pAccount );
                 }
+                g_free( s );
                 l_accounts_needing_parents = g_list_delete_link( l_accounts_needing_parents, l_accounts_needing_parents );
             }
         }



More information about the gnucash-changes mailing list