htdig: delete [] shoud be used instead of delete alone in some places


Stephan Muehlstrasser (smuehlst@Rational.Com)
Mon, 23 Mar 1998 16:04:52 +0100


Hi there,

I found some places in the source code of htdig-3.0.8b2 where the wrong
delete without [] is used for allocated arrays. This does not expose an
actual problem on my platform (Solaris, gcc-2.7.2) where I'm using
htdig, but it could be a problem for ports to other platforms/compilers.
I also added some deletes for fixing memory leaks.

I enclose the diffs for the files I modified.

Regards
Stephan

-- 
Stephan Muehlstrasser          +49-89-613769-30 (phone)
Regional Systems Engineer      +49-172-9096725  (mobile)
Rational GmbH                  +49-89-613769-69 (fax)
Keltenring 15                  http://www.rational.com/
D-82041 Oberhaching            mailto:smuehlst@rational.com

*** htdig-3.0.8b2/htlib/String.cc Fri Aug 15 07:59:38 1997 --- ../htdig-3.0.8b2/htlib/String.cc Mon Mar 23 14:12:19 1998 *************** *** 89,95 **** String::~String() { if (Data) ! delete Data; } void String::operator = (String &s) --- 89,95 ---- String::~String() { if (Data) ! delete [] Data; } void String::operator = (String &s) *************** *** 551,557 **** if (old_data) { copy_data_from(old_data, old_data_len); ! delete old_data; } } } --- 551,557 ---- if (old_data) { copy_data_from(old_data, old_data_len); ! delete [] old_data; } } } *** htdig-3.0.8b2/htlib/StringMatch.cc Fri Aug 15 07:59:38 1997 --- ../htdig-3.0.8b2/htlib/StringMatch.cc Mon Mar 23 14:20:58 1998 *************** *** 54,62 **** StringMatch::~StringMatch() { for (int i = 0; i < 256; i++) ! delete table[i]; if (local_alloc) ! delete trans; } --- 54,62 ---- StringMatch::~StringMatch() { for (int i = 0; i < 256; i++) ! delete [] table[i]; if (local_alloc) ! delete [] trans; } *************** *** 451,457 **** void StringMatch::TranslationTable(char *table) { if (local_alloc) ! delete trans; trans = (unsigned char *) table; local_alloc = 0; } --- 451,457 ---- void StringMatch::TranslationTable(char *table) { if (local_alloc) ! delete [] trans; trans = (unsigned char *) table; local_alloc = 0; } *** htdig-3.0.8b2/htsearch/Display.cc Fri Aug 15 07:59:44 1997 --- ../htdig-3.0.8b2/htsearch/Display.cc Mon Mar 23 15:00:18 1998 *************** *** 59,64 **** --- 59,65 ---- //***************************************************************************** Display::~Display() { + delete docIndex; } //***************************************************************************** *************** *** 88,93 **** --- 89,95 ---- // // No matches. // + delete matches; displayNomatch(); return; } *************** *** 125,130 **** --- 127,134 ---- expandVariables(currentTemplate->getEndTemplate()); } displayFooter(); + + delete matches; } //***************************************************************************** *************** *** 821,827 **** { matches->Add(array[i]); } ! delete array; } //***************************************************************************** --- 825,831 ---- { matches->Add(array[i]); } ! delete [] array; } //*****************************************************************************

---------------------------------------------------------------------- To unsubscribe from the htdig mailing list, send a message to htdig-request@sdsu.edu containing the single word "unsubscribe" in the body of the message.



This archive was generated by hypermail 2.0b3 on Sat Jan 02 1999 - 16:25:50 PST