After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 436920 - crash on loading OFX data for a commodity that exists without cusip field
crash on loading OFX data for a commodity that exists without cusip field
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Import - OFX
2.0.x
Other Mac OS
: Normal critical
: ---
Assigned To: Benoit Grégoire
Benoit Grégoire
Depends on:
Blocks: backport
 
 
Reported: 2007-05-08 15:30 UTC by David Osguthorpe
Modified: 2018-06-29 21:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix crash reported as bug 436920 (1.08 KB, patch)
2007-05-09 16:43 UTC, David Osguthorpe
committed Details | Review

Description David Osguthorpe 2007-05-08 15:30:34 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);
     }
Comment 1 Christian Stimming 2007-05-09 08:27:24 UTC
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.
Comment 2 David Osguthorpe 2007-05-09 16:43:54 UTC
Created attachment 87893 [details] [review]
Patch to fix crash reported as bug 436920

Patch attached as requested
Comment 3 Rolf Leggewie 2008-07-11 15:45:42 UTC
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?
Comment 4 Christian Stimming 2008-10-26 22:02:28 UTC
Committed to trunk, r17663, awaiting back-port. Thanks a lot!
Comment 5 John Ralls 2018-06-29 21:36:16 UTC
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.