[sword-devel] THE BIGGEST BUG ;-)

Troy A. Griffitts sword-devel@crosswire.org
Mon, 08 Nov 1999 07:47:34 +0000


> I discovered a REALLY BIG BUG! It's a big memory leak! The bug occurs in every
> SWORD 1.4x version.

Congratulations!  You win!

:)


> Open BibleTime, set the lower search bound in the searchscope dialog to
> something like "Matthew"  and type in the upper bound _nothing_. (no text).
> Start search for a word like "Jesus".
> Wait 10 minutes and your computer will be DEAD!
> 
> SWORD searches until infinity and will eat every mem avaible

Joachim,
	The problem is that I don't check for upper bounds being less than
lower bounds.  When "" or something similar is sent to upper bounds ""
is parsed to "Gen 1:1" then the last chapter and verse are applied sense
none were specified and it is 'upper' bounds, and I'd bet a shiny
dreckel that you end up with something like 'Genesis 50:26' as your
upper bounds.  However, I still cannot compile bibletime (I'm pretty
sure I'm in a group of all RH6.1 users who will probably have trouble
also).  I could write a simple test program to do the same thing, but
before I do, you might try putting a simple check in
...sword/src/keys/versekey.cpp: VerseKey::UpperBound(...):
something like:

if (*upperBound < *lowerBound)	//* so we don't check the pointer addr :)
	*upperBound = *lowerBound;

Or in the contructor that takes min and max, if 1 of these is null or ""
or whatever you are passing if nothing is entered, don't call the
[Upper|Lower]Bound method.

	Let me know if you don't get it fixed, or don't have time, and I will
look into the fix.  If you get it working, send me that patch! (diff -u
versekey.cpp.orig versekey.cpp is fine, you don't have to diff the whole
tree as I'm pretty sure the fix will be in this file.)

	Thanks Joachim!,
		-Troy.