[Gnucash-changes] Fix double-free error in generic importer.

Christian Stimming cstim at cvs.gnucash.org
Sun Oct 16 05:41:19 EDT 2005


Log Message:
-----------
Fix double-free error in generic importer.

2005-10-16  Christian Stimming  <stimming at tuhh.de>

        * src/import-export/import-backend.c: Woohoo! Tracked down and
        fixed a nasty double-free error when the importer reconciled
        existing transactions.

Tags:
----
gnucash-1-8-branch

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/import-export:
        import-backend.c

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1461.2.423
retrieving revision 1.1461.2.424
diff -LChangeLog -LChangeLog -u -r1.1461.2.423 -r1.1461.2.424
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,9 @@
+2005-10-16  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/import-backend.c: Woohoo! Tracked down and
+	fixed a nasty double-free error when the importer reconciled
+	existing transactions.
+
 2005-10-07  Christian Stimming  <stimming at tuhh.de>
 
 	* src/engine/iso-4217-currencies.scm: Fix spelling of TJS
Index: import-backend.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-backend.c,v
retrieving revision 1.13.2.9
retrieving revision 1.13.2.10
diff -Lsrc/import-export/import-backend.c -Lsrc/import-export/import-backend.c -u -r1.13.2.9 -r1.13.2.10
--- src/import-export/import-backend.c
+++ src/import-export/import-backend.c
@@ -106,7 +106,7 @@
 {
   Transaction * trans;
   Split * split;
-  //GNC_match_probability probability;
+  /*GNC_match_probability probability;*/
   gint probability;
 };
 
@@ -242,8 +242,8 @@
 {
   if (info) {
     g_list_free (info->match_list);
-    /*If the transaction is still open, it must be destroyed*/
-    if(xaccTransIsOpen(info->trans)==TRUE)
+    /*If the transaction exists and is still open, it must be destroyed*/
+    if(info->trans && xaccTransIsOpen(info->trans))
       {
 	xaccTransDestroy(info->trans);
 	xaccTransCommitEdit(info->trans);
@@ -936,6 +936,8 @@
 	      xaccTransDestroy(trans_info->trans);
 	      /*DEBUG("CommitEdit trans")*/
 	      xaccTransCommitEdit(trans_info->trans);
+	      /* Very important: Make sure the freed transaction is not freed again! */
+	      trans_info->trans = NULL;
 	    }
 	  break;
 	case GNCImport_EDIT:
@@ -983,7 +985,7 @@
     }
   else
     {
-      //printf("test_trans_online_id(): Duplicate found\n");
+      /*printf("test_trans_online_id(): Duplicate found\n");*/
       return FALSE;
     }
 }


More information about the gnucash-changes mailing list