a-coinho-shared.adb, [...]: Proper structures for tampering checks.
authorEd Schonberg <schonberg@adacore.com>
Wed, 16 Jul 2014 13:52:30 +0000 (13:52 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 16 Jul 2014 13:52:30 +0000 (15:52 +0200)
2014-07-16  Ed Schonberg  <schonberg@adacore.com>

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

From-SVN: r212642

gcc/ada/ChangeLog
gcc/ada/a-coinho-shared.adb
gcc/ada/a-coinho-shared.ads

index eebff9e128b04351ee2174f44d8d9a74ae167b41..e18dff08d6bea0f7bb9fcc9c078a1d4b487f85ec 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 4bcfb71518d7632b4a1e1a922f0ea77f82ecc11e..c9f117ebcfea3532654b50f791533fb7798e680e 100644 (file)
@@ -65,7 +65,12 @@ package body Ada.Containers.Indefinite_Holders is
    overriding procedure Adjust (Control : in out Reference_Control_Type) is
    begin
       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 Adjust;
 
@@ -115,9 +120,12 @@ package body Ada.Containers.Indefinite_Holders is
    is
       Ref : constant Constant_Reference_Type :=
               (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
-      Reference (Ref.Control.Container);
+      Reference (Ref.Control.Container.Reference);
+         B := B + 1;
       return Ref;
    end Constant_Reference;
 
@@ -168,7 +176,8 @@ package body Ada.Containers.Indefinite_Holders is
    overriding procedure Finalize (Control : in out Reference_Control_Type) is
    begin
       if Control.Container /= null then
-         Unreference (Control.Container);
+         Unreference (Control.Container.Reference);
+         Control.Container.Busy := Control.Container.Busy - 1;
       end if;
 
       Control.Container := null;
@@ -284,9 +293,10 @@ package body Ada.Containers.Indefinite_Holders is
    is
       Ref : constant Reference_Type :=
               (Element => Container.Reference.Element.all'Access,
-               Control => (Controlled with Container.Reference));
+               Control => (Controlled with Container'Unrestricted_Access));
    begin
-      Reference (Ref.Control.Container);
+      Reference (Ref.Control.Container.Reference);
+      Container.Busy := Container.Busy + 1;
       return Ref;
    end Reference;
 
index e97a64af655409281a14aa8b507690a79c7b9a22..8294d8e6a270d2d973e4f05c6d5ec20cbfb75176 100644 (file)
@@ -97,6 +97,7 @@ private
    use Ada.Streams;
 
    type Element_Access is access all Element_Type;
+   type Holder_Access is access all Holder;
 
    type Shared_Holder is record
       Counter : System.Atomic_Counters.Atomic_Counter;
@@ -131,7 +132,7 @@ private
 
    type Reference_Control_Type is new Controlled with
    record
-      Container : Shared_Holder_Access;
+      Container : Holder_Access;
    end record;
 
    overriding procedure Adjust (Control : in out Reference_Control_Type);