mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-11-02 09:49:06 -06:00
[gnc-plugin-page-report] plug char* leaks
also move a few lines later to avoid confirming double filepath != nullptr confirmation
This commit is contained in:
1 parent
c129e4de3c
commit
058568eab3
1 file changed
+10
-6
@@ -1604,12 +1604,6 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent)
|
||||
filepath = gnc_file_dialog (parent, title, nullptr, default_dir,
|
||||
GNC_FILE_DIALOG_EXPORT);
|
||||
|
||||
if (filepath != nullptr) // test for cancel pressed
|
||||
{
|
||||
/* Try to test for extension on file name, add if missing */
|
||||
if (g_strrstr(filepath, ".") == nullptr)
|
||||
filepath = g_strconcat(filepath, ".", g_ascii_strdown(type, strlen(type)), nullptr);
|
||||
}
|
||||
g_free (type);
|
||||
g_free (title);
|
||||
g_free (default_dir);
|
||||
@@ -1617,6 +1611,16 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent)
|
||||
if (!filepath)
|
||||
return nullptr;
|
||||
|
||||
/* Try to test for extension on file name, add if missing */
|
||||
if (strchr (filepath, '.') == nullptr)
|
||||
{
|
||||
char* extension = g_ascii_strdown (type, -1);
|
||||
char* newpath = g_strdup_printf ("%s.%s", filepath, extension);
|
||||
g_free (extension);
|
||||
g_free (filepath);
|
||||
filepath = newpath;
|
||||
}
|
||||
|
||||
default_dir = g_path_get_dirname(filepath);
|
||||
gnc_set_default_directory (GNC_PREFS_GROUP_REPORT, default_dir);
|
||||
g_free(default_dir);
|
||||
|
||||
Reference in new issue
Block a user