Skip to content

Commit ac92388

Browse files
[gnc-plugin-page-report] avoid UAF from 058568e
1 parent 7bdf31f commit ac92388

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

gnucash/gnome/gnc-plugin-page-report.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,15 +1604,8 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent)
16041604
filepath = gnc_file_dialog (parent, title, nullptr, default_dir,
16051605
GNC_FILE_DIALOG_EXPORT);
16061606

1607-
g_free (type);
1608-
g_free (title);
1609-
g_free (default_dir);
1610-
1611-
if (!filepath)
1612-
return nullptr;
1613-
16141607
/* Try to test for extension on file name, add if missing */
1615-
if (strchr (filepath, '.') == nullptr)
1608+
if (filepath && strchr (filepath, '.') == nullptr)
16161609
{
16171610
char* extension = g_ascii_strdown (type, -1);
16181611
char* newpath = g_strdup_printf ("%s.%s", filepath, extension);
@@ -1621,6 +1614,13 @@ gnc_get_export_filename (SCM choice, GtkWindow *parent)
16211614
filepath = newpath;
16221615
}
16231616

1617+
g_free (type);
1618+
g_free (title);
1619+
g_free (default_dir);
1620+
1621+
if (!filepath)
1622+
return nullptr;
1623+
16241624
default_dir = g_path_get_dirname(filepath);
16251625
gnc_set_default_directory (GNC_PREFS_GROUP_REPORT, default_dir);
16261626
g_free(default_dir);

0 commit comments

Comments
 (0)