[goffice] Conf: handle NULL keys better in Win32 backend.



commit f44284084cf6f173c98662fbba10ead35c4b4fec
Author: Morten Welinder <terra gnome org>
Date:   Thu Jul 9 11:01:50 2009 -0400

    Conf: handle NULL keys better in Win32 backend.

 ChangeLog                   |    5 +++++
 NEWS                        |    1 +
 goffice/app/go-conf-win32.c |   20 +++++++++++---------
 3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4202e4b..05936c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-09  Morten Welinder  <terra gnome org>
+
+	* goffice/app/go-conf-win32.c (go_conf_win32_get,
+	go_conf_win32_set): Handle NULL key.
+
 2009-07-01  Morten Welinder  <terra gnome org>
 
 	* goffice/app/go-conf-gconf.c (go_conf_add_monitor): Don't use
diff --git a/NEWS b/NEWS
index 2e36b8f..483960b 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Jean:
 
 Morten:
 	* Fix format localization problem. [#586567]
+	* Fix crash with Win32 configuration.  [#588138]
 
 --------------------------------------------------------------------------
 goffice 0.7.8:
diff --git a/goffice/app/go-conf-win32.c b/goffice/app/go-conf-win32.c
index 5b08ebb..5a433cb 100644
--- a/goffice/app/go-conf-win32.c
+++ b/goffice/app/go-conf-win32.c
@@ -53,16 +53,17 @@ go_conf_win32_set (GOConfNode *node, gchar const *key,
 	HKEY hKey;
 	gboolean ok;
 
-	if ((last_sep = strrchr (key, '/')) != NULL) {
+	last_sep = key ? strrchr (key, '/') : NULL;
+	if (last_sep) {
 		path = g_strndup (key, last_sep - key);
 		ok = go_conf_win32_get_node (node, &hKey, path, NULL);
 		g_free (path);
 		if (!ok)
 			return FALSE;
 		key = last_sep + 1;
-	}
-	else
+	} else
 		hKey = node->hKey;
+
 	RegSetValueEx (hKey, key, 0, type, data, size);
 	if (path)
 		RegCloseKey (hKey);
@@ -73,30 +74,31 @@ go_conf_win32_set (GOConfNode *node, gchar const *key,
 static gboolean
 go_conf_win32_get (GOConfNode *node, gchar const *key,
 		   gulong *type, guchar **data, gulong *size,
-		   gboolean realloc, gint *ret_code)
+		   gboolean do_realloc, gint *ret_code)
 {
 	gchar *last_sep, *path = NULL;
 	HKEY hKey;
 	LONG ret;
 	gboolean ok;
 
-	if ((last_sep = strrchr (key, '/')) != NULL) {
+	last_sep = key ? strrchr (key, '/') : NULL;
+	if (last_sep) {
 		path = g_strndup (key, last_sep - key);
 		ok = go_conf_win32_get_node (node, &hKey, path, NULL);
 		g_free (path);
 		if (!ok)
 			return FALSE;
 		key = last_sep + 1;
-	}
-	else
+	} else
 		hKey = node->hKey;
-	if (!*data && realloc) {
+
+	if (!*data && do_realloc) {
 		RegQueryValueEx (hKey, key, NULL, type, NULL, size);
 		*data = g_new (guchar, *size);
 	}
 	while ((ret = RegQueryValueEx (hKey, key, NULL,
 				       type, *data, size)) == ERROR_MORE_DATA &&
-	       realloc)
+	       d0_realloc)
 		*data = g_realloc (*data, *size);
 	if (path)
 		RegCloseKey (hKey);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]