This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix off-by-one error in GNAT.Perfect_Hash_Generators.Initialize


This patch cures an off-by-one error leading to a wild free:

   --  Deallocate the part of the table concerning the reduced words.
   --  Initial words are already present in the table. We may have reduced
   --  words already there because a previous computation failed. We are
   --  currently retrying and the reduced words have to be deallocated.

   for W in NK .. WT.Last loop
      Free_Word (WT.Table (W));
   end loop;

Reduced words actually start at NK + 1:

   function Reduced (K : Key_Id) return Word_Id is
   begin
      return K + NK + 1;
   end Reduced;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-04-16  Eric Botcazou  <ebotcazou@adacore.com>

	* g-pehage.adb (Initialize): Fix off-by-one error.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]