From: Steve Baird <[email protected]>
In the Adjust procedure for Ada.Containers.Bounded_Indefinite_Holders.Holder,
check to see whether the holder is empty before trying to copy its
(possibly nonexistent) element value.
gcc/ada/ChangeLog:
* libgnat/a-cbinho.adb (Adjust): Avoid null pointer dereference.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/libgnat/a-cbinho.adb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/libgnat/a-cbinho.adb b/gcc/ada/libgnat/a-cbinho.adb
index 8949bfe4c5d..5c5a8ed4139 100644
--- a/gcc/ada/libgnat/a-cbinho.adb
+++ b/gcc/ada/libgnat/a-cbinho.adb
@@ -48,8 +48,10 @@ package body Ada.Containers.Bounded_Indefinite_Holders is
overriding procedure Adjust (Container : in out Holder) is
begin
Container.Handle := Create_Subpool (The_Storage_Pool, Container);
- Container.Element :=
- new (Container.Handle) Element_Type'(Container.Element.all);
+ if Container.Element /= null then
+ Container.Element :=
+ new (Container.Handle) Element_Type'(Container.Element.all);
+ end if;
end Adjust;
------------
--
2.53.0