gnucash master: Fix free of non-malloced memory crash in SQL save slots.

John Ralls jralls at code.gnucash.org
Fri Oct 28 13:30:24 EDT 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/a808525d (commit)
	from  https://github.com/Gnucash/gnucash/commit/1e5f2459 (commit)



commit a808525d05f615ce9c9b2810c618cfe4bf7bda7f
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Oct 27 16:25:56 2016 -0700

    Fix free of non-malloced memory crash in SQL save slots.

diff --git a/src/backend/sql/gnc-slots-sql.cpp b/src/backend/sql/gnc-slots-sql.cpp
index 56febc9..5feafe2 100644
--- a/src/backend/sql/gnc-slots-sql.cpp
+++ b/src/backend/sql/gnc-slots-sql.cpp
@@ -665,10 +665,10 @@ save_slot (const gchar* key, KvpValue* value, gpointer data)
     break;
     case KvpValue::Type::GLIST:
     {
-        GncGUID guid = guid_new_return ();
-        slot_info_t* pNewInfo = slot_info_copy (pSlot_info, &guid);
+        GncGUID* guid = guid_new ();
+        slot_info_t* pNewInfo = slot_info_copy (pSlot_info, guid);
         KvpValue* oldValue = pSlot_info->pKvpValue;
-        pSlot_info->pKvpValue = new KvpValue {&guid};
+        pSlot_info->pKvpValue = new KvpValue {guid};  // Transfer ownership!
         pSlot_info->is_ok = gnc_sql_do_db_operation (pSlot_info->be,
                                                      OP_DB_INSERT, TABLE_NAME,
                                                      TABLE_NAME, pSlot_info,



Summary of changes:
 src/backend/sql/gnc-slots-sql.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list