Commit 3a859cff by Ed Schonberg Committed by Arnaud Charlet

a-coinho-shared.adb, [...]: Proper structures for tampering checks.

2014-07-16  Ed Schonberg  <schonberg@adacore.com>

	* a-coinho-shared.adb, a-coinho-shared.ads: Proper structures for
	tampering checks.

From-SVN: r212642
parent 88c90b68
2014-07-16 Ed Schonberg <schonberg@adacore.com> 2014-07-16 Ed Schonberg <schonberg@adacore.com>
* a-coinho-shared.adb, a-coinho-shared.ads: Proper structures for
tampering checks.
2014-07-16 Ed Schonberg <schonberg@adacore.com>
* a-coinho-shared.adb: Fix spurious accessibility check. * a-coinho-shared.adb: Fix spurious accessibility check.
2014-06-15 Jan Hubicka <hubicka@ucw.cz> 2014-06-15 Jan Hubicka <hubicka@ucw.cz>
......
...@@ -65,7 +65,12 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -65,7 +65,12 @@ package body Ada.Containers.Indefinite_Holders is
overriding procedure Adjust (Control : in out Reference_Control_Type) is overriding procedure Adjust (Control : in out Reference_Control_Type) is
begin begin
if Control.Container /= null then if Control.Container /= null then
Reference (Control.Container); Reference (Control.Container.Reference);
declare
B : Natural renames Control.Container.Busy;
begin
B := B + 1;
end;
end if; end if;
end Adjust; end Adjust;
...@@ -115,9 +120,12 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -115,9 +120,12 @@ package body Ada.Containers.Indefinite_Holders is
is is
Ref : constant Constant_Reference_Type := Ref : constant Constant_Reference_Type :=
(Element => Container.Reference.Element.all'Access, (Element => Container.Reference.Element.all'Access,
Control => (Controlled with Container.Reference)); Control => (Controlled with Container'Unrestricted_Access));
B : Natural renames Ref.Control.Container.Busy;
begin begin
Reference (Ref.Control.Container); Reference (Ref.Control.Container.Reference);
B := B + 1;
return Ref; return Ref;
end Constant_Reference; end Constant_Reference;
...@@ -168,7 +176,8 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -168,7 +176,8 @@ package body Ada.Containers.Indefinite_Holders is
overriding procedure Finalize (Control : in out Reference_Control_Type) is overriding procedure Finalize (Control : in out Reference_Control_Type) is
begin begin
if Control.Container /= null then if Control.Container /= null then
Unreference (Control.Container); Unreference (Control.Container.Reference);
Control.Container.Busy := Control.Container.Busy - 1;
end if; end if;
Control.Container := null; Control.Container := null;
...@@ -284,9 +293,10 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -284,9 +293,10 @@ package body Ada.Containers.Indefinite_Holders is
is is
Ref : constant Reference_Type := Ref : constant Reference_Type :=
(Element => Container.Reference.Element.all'Access, (Element => Container.Reference.Element.all'Access,
Control => (Controlled with Container.Reference)); Control => (Controlled with Container'Unrestricted_Access));
begin begin
Reference (Ref.Control.Container); Reference (Ref.Control.Container.Reference);
Container.Busy := Container.Busy + 1;
return Ref; return Ref;
end Reference; end Reference;
......
...@@ -97,6 +97,7 @@ private ...@@ -97,6 +97,7 @@ private
use Ada.Streams; use Ada.Streams;
type Element_Access is access all Element_Type; type Element_Access is access all Element_Type;
type Holder_Access is access all Holder;
type Shared_Holder is record type Shared_Holder is record
Counter : System.Atomic_Counters.Atomic_Counter; Counter : System.Atomic_Counters.Atomic_Counter;
...@@ -131,7 +132,7 @@ private ...@@ -131,7 +132,7 @@ private
type Reference_Control_Type is new Controlled with type Reference_Control_Type is new Controlled with
record record
Container : Shared_Holder_Access; Container : Holder_Access;
end record; end record;
overriding procedure Adjust (Control : in out Reference_Control_Type); overriding procedure Adjust (Control : in out Reference_Control_Type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment