gcc/ada/
* libgnat/a-strunb.ads (Unbounded_String): Reference is never
null.
* libgnat/a-strunb.adb (Finalize): Copy reference while it needs
to be deallocated.
-- Note: Don't try to free statically allocated null string
if Object.Reference /= Null_String'Access then
- Deallocate (Object.Reference);
- Object.Reference := Null_Unbounded_String.Reference;
+ declare
+ Reference_Copy : String_Access := Object.Reference;
+ -- The original reference cannot be null, so we must create a
+ -- copy which will become null when deallocated.
+ begin
+ Deallocate (Reference_Copy);
+ Object.Reference := Null_Unbounded_String.Reference;
+ end;
Object.Last := 0;
end if;
end Finalize;
renames To_Unbounded_String;
type Unbounded_String is new AF.Controlled with record
- Reference : String_Access := Null_String'Access;
- Last : Natural := 0;
+ Reference : not null String_Access := Null_String'Access;
+ Last : Natural := 0;
end record with Put_Image => Put_Image;
procedure Put_Image