patch: crasher bug.


Subject: patch: crasher bug.
From: Patrick Lam (plam@plam.lcs.mit.edu)
Date: Sat Apr 07 2001 - 00:29:33 CDT


I found this error while trying to paste text (in particular, the text of
bug 1011). I'm not sure if it clears any open bugs.

It happened that m_gbCharWidths.getLength() was greater than blockOffset.
I'm not sure that this should actually ever happen, but the patch at least
handles that case properly. The comment does suggest that pFirstNewRun
might be null, which is the case here. I hope to fix the two asserts
that pop up before this crashes now.

Furthermore, if pFirstNewRun is indeed null, then pLastRun should not be
set to NULL; its old value was correct. pLastRun always gets
dereferenced.

This fixes some broken code (I'm fairly sure) but doesn't actually fix the
whole problem yet.

pat

Index: src/text/fmt/xp/fl_BlockLayout.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fl_BlockLayout.cpp,v
retrieving revision 1.281
diff -u -r1.281 fl_BlockLayout.cpp
--- src/text/fmt/xp/fl_BlockLayout.cpp 2001/03/30 08:29:54 1.281
+++ src/text/fmt/xp/fl_BlockLayout.cpp 2001/04/07 05:27:50
@@ -3804,16 +3804,21 @@
                pFirstNewRun = pFirstNewRun->getNext();
        }
 
- pLastRun = NULL;
- if (pFirstNewRun && pFirstNewRun->getPrev())
+ if (pFirstNewRun)
        {
- // Break doubly-linked list of runs into two distinct
lists.
- // But remember the last Run in this block.
+ if (pFirstNewRun->getPrev())
+ {
+ // Break doubly-linked list of runs into two
distinct lists.
+ // But remember the last Run in this block.
 
- pLastRun = pFirstNewRun->getPrev();
- pFirstNewRun->getPrev()->setNext(NULL);
- pFirstNewRun->setPrev(NULL);
+ pLastRun = pFirstNewRun->getPrev();
+ pFirstNewRun->getPrev()->setNext(NULL);
+ pFirstNewRun->setPrev(NULL);
+ }
+ else
+ pLastRun = NULL;
        }
+ // else the old value of pLastRun is what we want.
 
        // pFirstNewRun can be NULL at this point. It means that the
        // entire set of runs in this block must remain with this block --
@@ -3825,7 +3830,7 @@
 
        // Split charwidths across the two blocks
        UT_uint32 lenNew = m_gbCharWidths.getLength() - blockOffset;
- if (lenNew > 0)
+ if (m_gbCharWidths.getLength() > blockOffset)
        {
                // NOTE: We do the length check on the outside for speed
                // TODO [1] can we move info from the current to the new



This archive was generated by hypermail 2b25 : Sat Apr 07 2001 - 00:32:57 CDT