gnucash master: Fix crash on attempting to load features from KVP if there aren't any.

John Ralls jralls at code.gnucash.org
Sun Jul 5 19:14:52 EDT 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/133f03d4 (commit)
	from  https://github.com/Gnucash/gnucash/commit/50787fc3 (commit)



commit 133f03d45aa5dd087ef7efb08c81391896a7cbd5
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Jul 5 16:14:33 2015 -0700

    Fix crash on attempting to load features from KVP if there aren't any.

diff --git a/src/libqof/qof/qofbook.cpp b/src/libqof/qof/qofbook.cpp
index d72cb6d..e34ee08 100644
--- a/src/libqof/qof/qofbook.cpp
+++ b/src/libqof/qof/qofbook.cpp
@@ -1066,8 +1066,12 @@ qof_book_get_features (QofBook *book)
     GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                   NULL, g_free);
 
-    frame = frame->get_slot(GNC_FEATURES)->get<KvpFrame*>();
-    frame->for_each_slot(&add_feature_to_hash, &features);
+    auto slot = frame->get_slot(GNC_FEATURES);
+    if (slot != nullptr)
+    {
+	frame = slot->get<KvpFrame*>();
+	frame->for_each_slot(&add_feature_to_hash, &features);
+    }
     return features;
 }
 



Summary of changes:
 src/libqof/qof/qofbook.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list