Fix/extend r17039 and make gnc_commodity_find_currency() free its temporary data.

BP


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17040 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2008-03-20 23:29:26 +00:00
parent 28d380651a
commit ecff4858c2

View File

@ -215,6 +215,7 @@ static gnc_commodity *
gnc_commodity_find_currency (QofBook *book, xmlNodePtr tree)
{
gnc_commodity_table * table;
gnc_commodity *currency = NULL;
gchar *exchange = NULL, *mnemonic = NULL;
xmlNodePtr node;
@ -226,22 +227,20 @@ gnc_commodity_find_currency (QofBook *book, xmlNodePtr tree)
mnemonic = (gchar*) xmlNodeGetContent (node->xmlChildrenNode);
}
if (!exchange || !mnemonic)
if (exchange
&& gnc_commodity_namespace_is_iso(exchange)
&& mnemonic)
{
if (exchange) xmlFree(exchange);
if (mnemonic) xmlFree(mnemonic);
return NULL;
}
if (!gnc_commodity_namespace_is_iso(exchange))
{
xmlFree(exchange);
xmlFree(mnemonic);
return NULL;
}
table = gnc_commodity_table_get_table(book);
return gnc_commodity_table_lookup(table, exchange, mnemonic);
currency = gnc_commodity_table_lookup(table, exchange, mnemonic);
}
if (exchange)
xmlFree(exchange);
if (mnemonic)
xmlFree(mnemonic);
return currency;
}
static gboolean