r15595 - gnucash/branches/2.0 - Add sanity checks when accessing GncPluginPage. Fixes #405851 and hopefully others.

Derek Atkins warlord at cvs.gnucash.org
Sun Feb 18 00:22:28 EST 2007


Author: warlord
Date: 2007-02-18 00:22:27 -0500 (Sun, 18 Feb 2007)
New Revision: 15595
Trac: http://svn.gnucash.org/trac/changeset/15595

Modified:
   gnucash/branches/2.0/
   gnucash/branches/2.0/ChangeLog
   gnucash/branches/2.0/src/import-export/hbci/gnc-plugin-hbci.c
Log:
Add sanity checks when accessing GncPluginPage. Fixes #405851 and hopefully others.

Merge from r15531.



Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
   - 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:14059
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
   + 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:14161
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282

Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog	2007-02-18 04:03:21 UTC (rev 15594)
+++ gnucash/branches/2.0/ChangeLog	2007-02-18 05:22:27 UTC (rev 15595)
@@ -1,3 +1,8 @@
+2007-02-18  Christian Stimming <stimming at tuhh.de>
+
+	Add sanity checks when accessing GncPluginPage. Fixes #405851 and
+	hopefully others.
+
 2007-02-04  Joshua Sled  <jsled at asynchronous.org>
 
 	Bug#168700: extension of fin.scm with cpd_{,i,p}pmt functions,

Modified: gnucash/branches/2.0/src/import-export/hbci/gnc-plugin-hbci.c
===================================================================
--- gnucash/branches/2.0/src/import-export/hbci/gnc-plugin-hbci.c	2007-02-18 04:03:21 UTC (rev 15594)
+++ gnucash/branches/2.0/src/import-export/hbci/gnc-plugin-hbci.c	2007-02-18 05:22:27 UTC (rev 15595)
@@ -297,17 +297,19 @@
   Account        *account = NULL;
 
   ENTER("main window %p", window);
-  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), NULL);
+  g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
 
   /* Ensure we are called from a register page. */
   page = gnc_main_window_get_current_page(window);
+  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
   page_name = gnc_plugin_page_get_plugin_name(page);
+  g_return_val_if_fail (page_name, NULL);
 
-  if (strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER_NAME) == 0) {
+  if (safe_strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER_NAME) == 0) {
     DEBUG("register page");
     account =
       gnc_plugin_page_register_get_account (GNC_PLUGIN_PAGE_REGISTER(page));
-  } else if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0) {
+  } else if (safe_strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0) {
     DEBUG("account tree page");
     account =
       gnc_plugin_page_account_tree_get_current_account (GNC_PLUGIN_PAGE_ACCOUNT_TREE(page));
@@ -332,8 +334,11 @@
   GtkActionGroup *action_group;
   GncMainWindow  *window;
 
+  g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
   window = GNC_MAIN_WINDOW(plugin_page->window);
+  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
   action_group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
+  g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
   gnc_plugin_update_actions(action_group, need_account_actions,
 			    "sensitive", account != NULL);
 }
@@ -347,8 +352,10 @@
   const gchar    *page_name;
 
   ENTER("main window %p, page %p", window, page);
+  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
   page_name = gnc_plugin_page_get_plugin_name(page);
-  if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0) {
+  g_return_if_fail (page_name);
+  if (safe_strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0) {
     DEBUG("account tree page, adding signal");
     g_signal_connect (G_OBJECT(page),
 		      "account_selected",
@@ -370,8 +377,9 @@
   Account        *account;
 
   ENTER("main window %p, page %p", window, page);
+  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
   action_group = gnc_main_window_get_action_group(window,PLUGIN_ACTIONS_NAME);
-  g_return_if_fail(action_group != NULL);
+  g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
 
   /* Reset everything to known state */
   gnc_plugin_update_actions(action_group, need_account_actions,
@@ -389,11 +397,12 @@
 
   /* Selectively make items visible */
   page_name = gnc_plugin_page_get_plugin_name(page);
-  if (strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0) {
+  g_return_if_fail (page_name);
+  if (safe_strcmp(page_name, GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME) == 0) {
     DEBUG("account tree page");
     gnc_plugin_update_actions(action_group, account_tree_actions,
 			      "visible", TRUE);
-  } else if (strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER_NAME) == 0) {
+  } else if (safe_strcmp(page_name, GNC_PLUGIN_PAGE_REGISTER_NAME) == 0) {
     DEBUG("register page");
     gnc_plugin_update_actions(action_group, register_actions,
 			      "visible", TRUE);



More information about the gnucash-changes mailing list