mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix memory leaks in dialog-file-acces.c:geturl
This commit is contained in:
parent
4b398325ea
commit
aaa71f2250
@ -71,33 +71,35 @@ static gchar*
|
|||||||
geturl( FileAccessWindow* faw )
|
geturl( FileAccessWindow* faw )
|
||||||
{
|
{
|
||||||
gchar* url = NULL;
|
gchar* url = NULL;
|
||||||
const gchar* host;
|
const gchar* host = NULL;
|
||||||
const gchar* database;
|
const gchar* database = NULL;
|
||||||
const gchar* username;
|
const gchar* username = NULL;
|
||||||
const gchar* password;
|
const gchar* password = NULL;
|
||||||
const gchar* type;
|
/* Not const as return value of gtk_combo_box_text_get_active_text must be freed */
|
||||||
const gchar* file;
|
gchar* type = NULL;
|
||||||
const gchar* path;
|
/* Not const as return value of gtk_file_chooser_get_filename must be freed */
|
||||||
|
gchar* path = NULL;
|
||||||
|
|
||||||
host = gtk_entry_get_text( faw->tf_host );
|
type = gtk_combo_box_text_get_active_text (faw->cb_uri_type);
|
||||||
database = gtk_entry_get_text( faw->tf_database );
|
if (gnc_uri_is_file_protocol (type))
|
||||||
username = gtk_entry_get_text( faw->tf_username );
|
|
||||||
password = gtk_entry_get_text( faw->tf_password );
|
|
||||||
file = gtk_file_chooser_get_filename( faw->fileChooser );
|
|
||||||
|
|
||||||
type = gtk_combo_box_text_get_active_text(faw->cb_uri_type );
|
|
||||||
if ( gnc_uri_is_file_protocol( type ) )
|
|
||||||
{
|
{
|
||||||
if ( file == NULL ) /* file protocol was chosen but no filename was set */
|
path = gtk_file_chooser_get_filename (faw->fileChooser);
|
||||||
|
if ( !path ) /* file protocol was chosen but no filename was set */
|
||||||
return NULL;
|
return NULL;
|
||||||
else /* file protocol was chosen with filename set */
|
|
||||||
path = file;
|
|
||||||
}
|
}
|
||||||
else /* db protocol was chosen */
|
else /* db protocol was chosen */
|
||||||
path = database;
|
{
|
||||||
|
host = gtk_entry_get_text( faw->tf_host );
|
||||||
|
path = g_strdup(gtk_entry_get_text(faw->tf_database));
|
||||||
|
username = gtk_entry_get_text( faw->tf_username );
|
||||||
|
password = gtk_entry_get_text( faw->tf_password );
|
||||||
|
}
|
||||||
|
|
||||||
url = gnc_uri_create_uri (type, host, 0, username, password, path);
|
url = gnc_uri_create_uri (type, host, 0, username, password, path);
|
||||||
|
|
||||||
|
g_free (type);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user