gnucash maint: [gnucash.cpp] char* must be freed.

Christopher Lam clam at code.gnucash.org
Tue Jun 21 11:41:13 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/f7cdc196 (commit)
	from  https://github.com/Gnucash/gnucash/commit/418de906 (commit)



commit f7cdc19695ddbfc8f56d603ea1bc9c773afda5aa
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 21 23:39:44 2022 +0800

    [gnucash.cpp] char* must be freed.
    
    g_option_context_get_help() returns a char* which must be freed.

diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp
index 1be769bfb..dd7257116 100644
--- a/gnucash/gnucash.cpp
+++ b/gnucash/gnucash.cpp
@@ -272,7 +272,10 @@ Gnucash::Gnucash::configure_program_options (void)
     auto context = g_option_context_new (m_tagline.c_str());
     auto gtk_options = gtk_get_option_group(FALSE);
     g_option_context_add_group (context, gtk_options);
-    m_gtk_help_msg = g_option_context_get_help (context, FALSE, gtk_options);
+
+    auto help_cstr = g_option_context_get_help (context, FALSE, gtk_options);
+    m_gtk_help_msg = help_cstr;
+    g_free (help_cstr);
     g_option_context_free (context);
 
     bpo::options_description app_options(_("Application Options"));



Summary of changes:
 gnucash/gnucash.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list