Skip to content

Commit fcf2fc5

Browse files
[gnc-prefs.cpp] plug gchar* leak
namespace_regexp was never freed upon shutdown
1 parent 5c5b32a commit fcf2fc5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

libgnucash/core-utils/gnc-prefs.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@
2121
* Boston, MA 02110-1301, USA gnu@gnu.org
2222
*/
2323

24+
#include <string>
25+
2426
#include <stdlib.h>
2527
#include <glib.h>
2628
#include <config.h>
2729
#include "gnc-prefs.h"
2830
#include "gnc-prefs-p.h"
2931
#include "gnc-version.h"
3032

31-
static gchar *namespace_regexp = NULL;
33+
static std::string namespace_regexp;
3234
static gboolean is_debugging = FALSE;
3335
static gboolean extras_enabled = FALSE;
3436
static gboolean use_compression = TRUE; // This is also the default in the prefs backend
@@ -46,17 +48,14 @@ PrefsBackend *prefsbackend = NULL;
4648
const gchar *
4749
gnc_prefs_get_namespace_regexp(void)
4850
{
49-
return namespace_regexp;
51+
return namespace_regexp.c_str();
5052
}
5153

5254
void
5355
gnc_prefs_set_namespace_regexp(const gchar *str)
5456
{
55-
if (namespace_regexp)
56-
g_free(namespace_regexp);
57-
5857
if (str)
59-
namespace_regexp = g_strdup(str);
58+
namespace_regexp = str;
6059
}
6160

6261
gboolean

0 commit comments

Comments
 (0)