Bug #436920: Fix crash on loading OFX data for a commodity that exists without cusip field

Original patch included also the fix of r16884, which was applied earlier already.

Patch by David Osguthorpe.
BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17663 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2008-10-26 22:01:58 +00:00
parent b6c3ac3f4d
commit e7c97f06da

View File

@ -121,6 +121,12 @@ gnc_commodity * gnc_import_select_commodity(char * cusip,
default_mnemonic);
}
/* There seems to be a problem here - if the matched commodity does not
have a cusip defined (gnc_commodity_get_cusip returns NULL) then
it does not get overwritten - which is not consistent with the
message - so Im adding it to do this. Looks like this is all
that was needed to fix the cash value used as stock units problem
for pre-defined commodities which didnt have the cusip defined! */
if (retval != NULL&&
gnc_commodity_get_cusip(retval)!=NULL &&
cusip != NULL &&
@ -128,6 +134,10 @@ gnc_commodity * gnc_import_select_commodity(char * cusip,
{
gnc_commodity_set_cusip(retval, cusip);
}
else if (gnc_commodity_get_cusip(retval)==NULL && cusip != NULL)
{
gnc_commodity_set_cusip(retval, cusip);
}
return retval;
};
/**@}*/