[Gnucash-changes] fix null pointer deref

Linas Vepstas linas at cvs.gnucash.org
Fri Aug 27 14:46:44 EDT 2004


Log Message:
-----------
fix null pointer deref

Modified Files:
--------------
    gnucash/src/engine:
        cap-gains.c

Revision Data
-------------
Index: cap-gains.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/cap-gains.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lsrc/engine/cap-gains.c -Lsrc/engine/cap-gains.c -u -r1.30 -r1.31
--- src/engine/cap-gains.c
+++ src/engine/cap-gains.c
@@ -709,28 +709,30 @@
 
    if (GAINS_STATUS_GAINS & split->gains)
    {
+		Split *s;
       PINFO ("split is a gains recording split, switch over");
       /* If this is the split that records the gains, then work with 
        * the split that generates the gains. 
        */
       /* split = xaccSplitGetCapGainsSplit (split); */
-      split = split->gains_split;
+      s = split->gains_split;
 
       /* This should never be NULL, and if it is, and its matching
        * parent can't be found, then its a bug, and we should be
        * discarding this split.   But ... for now .. return.
        * XXX move appropriate actions to a 'scrub' routine'
        */
-      if (!split) 
+      if (!s) 
       {
          PERR ("Bad gains-split pointer! .. trying to recover.");
          split->gains_split = xaccSplitGetCapGainsSplit (split);
-         split = split->gains_split;
-         if (!split) return;
+         s = split->gains_split;
+         if (!s) return;
 #if MOVE_THIS_TO_A_DATA_INTEGRITY_SCRUBBER 
          xaccTransDestroy (trans);
 #endif
       }
+		split = s;
    }
 
    /* Note: if the value of the 'opening' split(s) has changed,


More information about the gnucash-changes mailing list