r20018 - gnucash/trunk/src/backend/sql - Plug more memory leaks

Phil Longstaff plongstaff at code.gnucash.org
Fri Dec 31 11:53:19 EST 2010


Author: plongstaff
Date: 2010-12-31 11:53:18 -0500 (Fri, 31 Dec 2010)
New Revision: 20018
Trac: http://svn.gnucash.org/trac/changeset/20018

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


Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c	2010-12-31 13:31:42 UTC (rev 20017)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c	2010-12-31 16:53:18 UTC (rev 20018)
@@ -1778,9 +1778,10 @@
                           const gpointer pObject, const GncSqlColumnTableEntry* table_row, GSList** pList )
 {
     QofAccessFunc getter;
-    const GncGUID* guid = NULL;
+    GncGUID* guid = NULL;
     gchar guid_buf[GUID_ENCODING_LENGTH+1];
     GValue* value;
+    gboolean free_guid = FALSE;
 
     g_return_if_fail( be != NULL );
     g_return_if_fail( obj_name != NULL );
@@ -1792,6 +1793,7 @@
     if ( table_row->gobj_param_name != NULL )
     {
         g_object_get( pObject, table_row->gobj_param_name, &guid, NULL );
+        free_guid = TRUE;
     }
     else
     {
@@ -1809,6 +1811,11 @@
     }
 
     (*pList) = g_slist_append( (*pList), value );
+
+    if ( free_guid )
+    {
+        g_free( guid );
+    }
 }
 
 static GncSqlColumnTypeHandler guid_handler

Modified: gnucash/trunk/src/backend/sql/gnc-slots-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-slots-sql.c	2010-12-31 13:31:42 UTC (rev 20017)
+++ gnucash/trunk/src/backend/sql/gnc-slots-sql.c	2010-12-31 16:53:18 UTC (rev 20018)
@@ -500,6 +500,7 @@
         slots_load_info( newInfo );
         pValue = kvp_value_new_glist_nc( newInfo->pList );
         kvp_frame_set_slot_nc(pInfo->pKvpFrame, key, pValue);
+        g_string_free( newInfo->path, TRUE );
         g_slice_free( slot_info_t, newInfo );
         g_free( key );
         break;
@@ -533,6 +534,7 @@
 
         newInfo->context = FRAME;
         slots_load_info ( newInfo );
+        g_string_free( newInfo->path, TRUE );
         g_slice_free( slot_info_t, newInfo );
         break;
     }
@@ -664,6 +666,7 @@
         kvp_frame_for_each_slot( pKvpFrame, save_slot, pNewInfo );
         kvp_value_delete( pSlot_info->pKvpValue );
         pSlot_info->pKvpValue = oldValue;
+        g_string_free( pNewInfo->path, TRUE );
         g_slice_free( slot_info_t, pNewInfo );
     }
     break;
@@ -686,6 +689,7 @@
         }
         kvp_value_delete( pSlot_info->pKvpValue );
         pSlot_info->pKvpValue = oldValue;
+        g_string_free( pNewInfo->path, TRUE );
         g_slice_free( slot_info_t, pNewInfo );
     }
     break;
@@ -780,13 +784,15 @@
 static void
 load_slot( slot_info_t *pInfo, GncSqlRow* row )
 {
-    slot_info_t *slot_info = slot_info_copy( pInfo, NULL );
+    slot_info_t *slot_info;
 
     g_return_if_fail( pInfo != NULL );
     g_return_if_fail( pInfo->be != NULL );
     g_return_if_fail( row != NULL );
     g_return_if_fail( pInfo->pKvpFrame != NULL );
 
+    slot_info = slot_info_copy( pInfo, NULL );
+    g_string_free( slot_info->path, TRUE );
     slot_info->path = NULL;
 
     gnc_sql_load_object( pInfo->be, row, TABLE_NAME, slot_info, col_table );



More information about the gnucash-changes mailing list