
From smuehlst@Rational.Com Fri Apr  3 23:35:55 1998
Date: Mon, 23 Mar 1998 16:04:52 +0100
From: Stephan Muehlstrasser <smuehlst@Rational.Com>
To: htdig@sdsu.edu
Cc: Stephan Muehlstrasser <smuehlst@Rational.Com>
Subject: htdig: delete [] shoud be used instead of delete alone in some places

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

  [Part 2, Text/PLAIN  126 lines]
  [Unable to print this part]

*** 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;
  }
  
  //*****************************************************************************
