GNOME Bugzilla – Bug 436920
crash on loading OFX data for a commodity that exists without cusip field
Last modified: 2018-06-29 21:36:16 UTC
If you have manually created a commodity without a cusip or other id field then import an OFX file with that commodity which includes a cusip ID and select that commodity gnucash crashes dead. The following patch fixes this - the main error is the re-use of tmp_commodity - the patch also fixes it to set the cusip field if the existing cusip field is NULL which is consistent with the dialog message. --- src/import-export/import-commodity-matcher.c.orig Sun Feb 18 20:40:15 2007 +++ src/import-export/import-commodity-matcher.c Sun May 6 08:16:08 2007 @@ -121,10 +121,21 @@ 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!! + // note also the bug fix of retval not tmp_commodity if (retval != NULL&& - gnc_commodity_get_cusip(tmp_commodity)!=NULL && + gnc_commodity_get_cusip(retval)!=NULL && cusip != NULL && (strncmp(gnc_commodity_get_cusip(retval),cusip,strlen(cusip))!=0)) + { + gnc_commodity_set_cusip(retval, cusip); + } + else if (gnc_commodity_get_cusip(retval)==NULL && cusip != NULL) { gnc_commodity_set_cusip(retval, cusip); }
Thanks for submitting this patch! We love such bugreports :-) However, could you please attach the patch as an attachment? ("Create a new attachment" below; this option appears in bugzilla only after initially posting the bugreport, sorry for that.) The current text version of your patch has probably messed up some line wrappings. Thanks.
Created attachment 87893 [details] [review] Patch to fix crash reported as bug 436920 Patch attached as requested
Comment on attachment 87893 [details] [review] Patch to fix crash reported as bug 436920 unfortunately, this patch did not make it in on time and now does not apply cleanly against the latest svn code. David would you be so kind to provide a rebased patch?
Committed to trunk, r17663, awaiting back-port. Thanks a lot!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=436920. Please update any external references or bookmarks.