From fcf2fc5f85a8d6de992d277478415f8f29d37bc5 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 14 Oct 2025 19:43:49 +0800 Subject: [PATCH] [gnc-prefs.cpp] plug gchar* leak namespace_regexp was never freed upon shutdown --- libgnucash/core-utils/gnc-prefs.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libgnucash/core-utils/gnc-prefs.cpp b/libgnucash/core-utils/gnc-prefs.cpp index f3d8503454..e94e5b7f7c 100644 --- a/libgnucash/core-utils/gnc-prefs.cpp +++ b/libgnucash/core-utils/gnc-prefs.cpp @@ -21,6 +21,8 @@ * Boston, MA 02110-1301, USA gnu@gnu.org */ +#include + #include #include #include @@ -28,7 +30,7 @@ #include "gnc-prefs-p.h" #include "gnc-version.h" -static gchar *namespace_regexp = NULL; +static std::string namespace_regexp; static gboolean is_debugging = FALSE; static gboolean extras_enabled = FALSE; static gboolean use_compression = TRUE; // This is also the default in the prefs backend @@ -46,17 +48,14 @@ PrefsBackend *prefsbackend = NULL; const gchar * gnc_prefs_get_namespace_regexp(void) { - return namespace_regexp; + return namespace_regexp.c_str(); } void gnc_prefs_set_namespace_regexp(const gchar *str) { - if (namespace_regexp) - g_free(namespace_regexp); - if (str) - namespace_regexp = g_strdup(str); + namespace_regexp = str; } gboolean