Add a check to avoid causing a buffer overflow when the map is empty
2019-07-11 Claire Dross <dross@adacore.com>
gcc/ada/
* libgnat/a-cfhama.adb, libgnat/a-cfhase.adb (Free): Do not
reset the Has_Element flag if no element is freed.
From-SVN: r273397
+2019-07-11 Claire Dross <dross@adacore.com>
+
+ * libgnat/a-cfhama.adb, libgnat/a-cfhase.adb (Free): Do not
+ reset the Has_Element flag if no element is freed.
+
2019-07-11 Arnaud Charlet <charlet@adacore.com>
* errno.c: Remove obsolete support for MaRTE OS.
procedure Free (HT : in out Map; X : Count_Type) is
begin
- HT.Nodes (X).Has_Element := False;
- HT_Ops.Free (HT, X);
+ if X /= 0 then
+ pragma Assert (X <= HT.Capacity);
+ HT.Nodes (X).Has_Element := False;
+ HT_Ops.Free (HT, X);
+ end if;
end Free;
----------------------
procedure Free (HT : in out Set; X : Count_Type) is
begin
- HT.Nodes (X).Has_Element := False;
- HT_Ops.Free (HT, X);
+ if X /= 0 then
+ pragma Assert (X <= HT.Capacity);
+ HT.Nodes (X).Has_Element := False;
+ HT_Ops.Free (HT, X);
+ end if;
end Free;
----------------------