gnucash stable: [gnc-plugin-page-report] plug char* leaks
Christopher Lam
clam at code.gnucash.org
Fri Oct 24 11:22:33 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/058568ea (commit)
from https://github.com/Gnucash/gnucash/commit/c129e4de (commit)
commit 058568eab3a59c9aa6e80f9aefbce84ee57ea1bc
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Oct 24 23:12:58 2025 +0800
[gnc-plugin-page-report] plug char* leaks
also move a few lines later to avoid confirming double filepath !=
nullptr confirmation
diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp b/gnucash/gnome/gnc-plugin-page-report.cpp
index 6f2743b4c5..ac835affdf 100644
--- a/gnucash/gnome/gnc-plugin-page-report.cpp
+++ b/gnucash/gnome/gnc-plugin-page-report.cpp
@@ -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);
Summary of changes:
gnucash/gnome/gnc-plugin-page-report.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
More information about the gnucash-changes
mailing list