RE: Commit: Really fixed Select-All - Paste Crash bug


Subject: RE: Commit: Really fixed Select-All - Paste Crash bug
From: WJCarpenter (bill-abisource@carpenter.ORG)
Date: Mon Nov 20 2000 - 13:25:51 CST


ms> Really Really Fixed select-All - paste crash bug! There was a
ms> hardwired array containing Smart Quote candidates! I changed it to
ms> 10000 for the time being until a better fix is found.

Extreme bonehead alert (me!). See below.

ms> Bill Carpenter should provide a nice elegent way of having an
ms> indefinite number of smart quotes. Offending Lines are:

        UT_uint32 _sqlist[100], *sqlist = _sqlist;
        UT_uint32 sqcount = 0;
        if (sizeof(_sqlist) / sizeof(_sqlist[0]) < len)
        {
                sqlist = new UT_uint32(len);
        }

The implementation already allows an indefinite number of SmartQuotes,
pastes of any size, etc. Unfortunately, it has a serious boner of a
bug in it.

                sqlist = new UT_uint32(len);
should be:
                sqlist = new UT_uint32[len];

As any fool should be able to guess, I wanted to allocate an array of
integers with "len" elements, not a pointer to a single integers with
value "len". Why the compiler can't read my mind of this is a mystery
to me. (How it passed my testing is an even bigger mystery. For
stuff like that, I generaly crank the static array size down to
something like [2] to make sure the alternative path gets exercised.
I guess I just got lucky/unlucky with the stack/heap when I did it.)

Clearly, changing "100" to "10000" just postpones the inevitable, and
someone pasting more then 10k chars would hit the same problem.

It will be at least a few days (probably over the US Thanksgiving
weekend) before I can get to even this simple thing. Could someone
fix up that "new" as indicated above, and change the "10000" back to
"100"? Lower in the code, there is also a "delete sqlist" that should
turn into a "delete[] sqlist". The code in
src/text/fmt/xp/fl_BlockLayout.cpp in function
fl_BlockLayout::doclistener_insertSpan().

As we say in the software biz, "Duh-oh!"

-- 
bill@carpenter.ORG (WJCarpenter)    PGP 0x91865119
38 95 1B 69 C9 C6 3D 25    73 46 32 04 69 D6 ED F3



This archive was generated by hypermail 2b25 : Mon Nov 20 2000 - 13:21:50 CST