mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix memory leak in char* type KvpValue and fix improper uses
The core issue was that the delete visitor was never called because its parameter type (char *) didn't match the boost::variant type (const char *). Fixing the visitor's parameter type also require a const_cast back to char * because that's what g_free takes as argument. The rest of this commit is merely fixing KvpValue instantiations that tried to create a char* KvpValue from a stack based const string instead of a heap allocated one. That would bomb out on calling the delete visitor.
This commit is contained in:
@@ -139,7 +139,7 @@ setup_memory (Fixture* fixture, gconstpointer pData)
|
||||
frame->set ({"double-val"}, new KvpValue (3.14159));
|
||||
frame->set ({"numeric-val"}, new KvpValue (gnc_numeric_zero ()));
|
||||
frame->set ({"time-val"}, new KvpValue (gnc_time(nullptr)));
|
||||
frame->set ({"string-val"}, new KvpValue ("abcdefghijklmnop"));
|
||||
frame->set ({"string-val"}, new KvpValue (g_strdup ("abcdefghijklmnop")));
|
||||
auto guid = qof_instance_get_guid (QOF_INSTANCE (acct1));
|
||||
frame->set ({"guid-val"}, new KvpValue (const_cast<GncGUID*> (guid_copy (
|
||||
guid))));
|
||||
|
||||
@@ -205,7 +205,7 @@ dom_tree_to_numeric_kvp_value (xmlNodePtr node)
|
||||
static KvpValue*
|
||||
dom_tree_to_string_kvp_value (xmlNodePtr node)
|
||||
{
|
||||
gchar* datext;
|
||||
const gchar* datext;
|
||||
KvpValue* ret = NULL;
|
||||
|
||||
datext = dom_tree_to_text (node);
|
||||
|
||||
Reference in New Issue
Block a user