r16672 - gnucash/branches/2.2/src/app-utils - [r16670] Bug#496178: freeing the result of guid_to_string(…) causes memory corruption; use guid_to_string_buff(…) for clarity.
Andreas Köhler
andi5 at cvs.gnucash.org
Sun Dec 16 13:41:23 EST 2007
Author: andi5
Date: 2007-12-16 13:41:23 -0500 (Sun, 16 Dec 2007)
New Revision: 16672
Trac: http://svn.gnucash.org/trac/changeset/16672
Modified:
gnucash/branches/2.2/src/app-utils/gnc-sx-instance-model.c
Log:
[r16670] Bug#496178: freeing the result of guid_to_string(…) causes memory corruption; use guid_to_string_buff(…) for clarity.
Patch from jsled.
Modified: gnucash/branches/2.2/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/branches/2.2/src/app-utils/gnc-sx-instance-model.c 2007-12-16 17:57:50 UTC (rev 16671)
+++ gnucash/branches/2.2/src/app-utils/gnc-sx-instance-model.c 2007-12-16 18:41:23 UTC (rev 16672)
@@ -261,11 +261,10 @@
gnc_sx_get_template_transaction_account(SchedXaction *sx)
{
Account *template_root, *sx_template_acct;
- const char *sx_guid_str;
+ char sx_guid_str[GUID_ENCODING_LENGTH];
template_root = gnc_book_get_template_root(gnc_get_current_book());
- sx_guid_str = guid_to_string(xaccSchedXactionGetGUID(sx));
- /* Get account named after guid string. */
+ guid_to_string_buff(xaccSchedXactionGetGUID(sx), sx_guid_str);
sx_template_acct = gnc_account_lookup_by_name(template_root, sx_guid_str);
return sx_template_acct;
}
@@ -922,13 +921,12 @@
*split_acct = xaccAccountLookup(acct_guid, gnc_get_current_book());
if (*split_acct == NULL)
{
- const char *guid_str;
+ char guid_str[GUID_ENCODING_LENGTH];
GString *err;
- guid_str = guid_to_string((const GUID*)acct_guid);
+ guid_to_string_buff((const GUID*)acct_guid, guid_str);
err = g_string_new("");
g_string_printf(err, "Unknown account for guid [%s], cancelling SX [%s] creation.",
guid_str, xaccSchedXactionGetName(instance->parent->sx));
- g_free((char*)guid_str);
g_critical("%s", err->str);
if (creation_errors != NULL)
*creation_errors = g_list_append(*creation_errors, err);
More information about the gnucash-changes
mailing list