gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Thu Nov 30 18:37:53 EST 2023
Updated via https://github.com/Gnucash/gnucash/commit/abb4a01a (commit)
via https://github.com/Gnucash/gnucash/commit/d8ece965 (commit)
via https://github.com/Gnucash/gnucash/commit/ca3c09c5 (commit)
from https://github.com/Gnucash/gnucash/commit/d8dacb86 (commit)
commit abb4a01ac8bbc689d84087939fc2d0dca7357d74
Merge: d8dacb86b2 d8ece96503
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Dec 1 07:37:17 2023 +0800
Merge branch 'stable-leaks' into stable #1831
commit d8ece96503ccf71550e0d0031bcd936e0af45bd1
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Thu Nov 30 22:16:53 2023 +0800
[gnc-engine-guile.cpp] plug runaway GSList* leak
The QofQuery param_list is a GSList of const char*. Every SCM Query
would typically leak the GSList. This change will store the params
into the string cache, and the cached string is passed onto the
QofQuery param.
diff --git a/bindings/guile/gnc-engine-guile.cpp b/bindings/guile/gnc-engine-guile.cpp
index 39f6d2db40..587674f800 100644
--- a/bindings/guile/gnc-engine-guile.cpp
+++ b/bindings/guile/gnc-engine-guile.cpp
@@ -386,17 +386,16 @@ gnc_query_scm2path (SCM path_scm)
if (!scm_is_list (path_scm))
return nullptr;
- while (!scm_is_null (path_scm))
+ for (; !scm_is_null (path_scm); path_scm = scm_cdr (path_scm))
{
SCM key_scm = SCM_CAR (path_scm);
- char *key;
if (!scm_is_string (key_scm))
break;
- key = gnc_scm_to_utf8_string(key_scm);
- path = g_slist_prepend (path, key);
- path_scm = SCM_CDR (path_scm);
+ auto key = gnc_scm_to_utf8_string(key_scm);
+ path = g_slist_prepend (path, (gpointer)qof_string_cache_insert(key));
+ g_free (key);
}
return g_slist_reverse (path);
@@ -405,12 +404,7 @@ gnc_query_scm2path (SCM path_scm)
static void
gnc_query_path_free (GSList *path)
{
- GSList *node;
-
- for (node = path; node; node = node->next)
- g_free (node->data);
-
- g_slist_free (path);
+ g_slist_free_full (path, (GDestroyNotify)qof_string_cache_remove);
}
commit ca3c09c5f644d0f2f94fb53aa931445631514cab
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Nov 27 20:53:56 2023 +0800
[dialog-report-column-view.cpp] new/delete instead of g_new/g_free
because the struct has vector objects which would otherwise leak.
diff --git a/gnucash/gnome/dialog-report-column-view.cpp b/gnucash/gnome/dialog-report-column-view.cpp
index 10f772b8ba..fcd6ab988e 100644
--- a/gnucash/gnome/dialog-report-column-view.cpp
+++ b/gnucash/gnome/dialog-report-column-view.cpp
@@ -61,7 +61,7 @@ using StrVec = std::vector<std::string>;
struct gncp_column_view_edit
{
- GncOptionsDialog * optwin;
+ std::unique_ptr<GncOptionsDialog> optwin;
GtkTreeView * available;
GtkTreeView * contents;
@@ -103,10 +103,9 @@ gnc_column_view_set_option(GncOptionDB* odb, const char* section,
static void
gnc_column_view_edit_destroy(gnc_column_view_edit * view)
{
- delete view->optwin;
scm_gc_unprotect_object(view->view);
gnc_option_db_destroy(view->odb);
- g_free(view);
+ delete view;
}
static StrVec
@@ -322,10 +321,10 @@ gnc_column_view_edit_options(GncOptionDB* odb, SCM view)
}
else
{
- gnc_column_view_edit * r = g_new0(gnc_column_view_edit, 1);
+ auto r = new gnc_column_view_edit;
GtkBuilder *builder;
- r->optwin = new GncOptionsDialog(nullptr, GTK_WINDOW(gnc_ui_get_main_window (nullptr)));
+ r->optwin = std::make_unique<GncOptionsDialog>(nullptr, GTK_WINDOW(gnc_ui_get_main_window (nullptr)));
/* Hide the generic dialog page list. */
gtk_widget_hide(r->optwin->get_page_list());
Summary of changes:
bindings/guile/gnc-engine-guile.cpp | 16 +++++-----------
gnucash/gnome/dialog-report-column-view.cpp | 9 ++++-----
2 files changed, 9 insertions(+), 16 deletions(-)
More information about the gnucash-changes
mailing list