r18443 - gnucash/trunk/src/gnome-utils - Fix Bug 591573 - "File|Save As" with xml option and no file name crashes

Phil Longstaff plongstaff at code.gnucash.org
Thu Nov 26 22:13:43 EST 2009


Author: plongstaff
Date: 2009-11-26 22:13:41 -0500 (Thu, 26 Nov 2009)
New Revision: 18443
Trac: http://svn.gnucash.org/trac/changeset/18443

Modified:
   gnucash/trunk/src/gnome-utils/dialog-file-access.c
Log:
Fix Bug 591573 -  "File|Save As" with xml option and no file name crashes

With no file name, entered, filename returned from file_chooser is NULL,
which led to the crash.  If NULL is returned, just ignore the button press.

Proper UI would not allow Save As to be clicked unless conditions were right,
but I'm not sure how to make that happen.  There is a signal emitted when a
file is selected, but not when characters are typed into the name text field.



Modified: gnucash/trunk/src/gnome-utils/dialog-file-access.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-file-access.c	2009-11-24 21:01:02 UTC (rev 18442)
+++ gnucash/trunk/src/gnome-utils/dialog-file-access.c	2009-11-27 03:13:41 UTC (rev 18443)
@@ -79,6 +79,9 @@
 
 	type = gtk_combo_box_get_active_text( faw->cb_uri_type );
 	if( strcmp( type, "xml" ) == 0 ) {
+	    if( file == NULL ) {
+		    return NULL;
+		}
 		url = g_strdup_printf( "xml://%s", file );
 	} else if( strcmp( type, "sqlite3" ) == 0 ) {
 		url = g_strdup_printf( "sqlite3://%s", file );
@@ -115,6 +118,9 @@
   
 	case GTK_RESPONSE_OK:
 		url = geturl( faw );
+		if( url == NULL ) {
+		    return;
+		}
 		if( faw->type == FILE_ACCESS_OPEN ) {
 			gnc_file_open_file( url );
 		} else if( faw->type == FILE_ACCESS_SAVE_AS ) {



More information about the gnucash-changes mailing list