2007-08-14 Cyrille Comar <comar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 08:49:45 +0000 (08:49 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 08:49:45 +0000 (08:49 +0000)
* s-finimp.adb (Detach_From_Final_List): make this procedure idempotent
since it is potentially used in cases implying double finalization of
the same object.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127462 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/s-finimp.adb

index 4f6c4c1..4ed7c6c 100644 (file)
@@ -258,7 +258,7 @@ package body System.Finalization_Implementation is
    -----------------------------
 
    --  We know that the detach object is neither at the beginning nor at the
-   --  end of the list, thank's to the dummy First and Last Elements but the
+   --  end of the list, thanks to the dummy First and Last Elements, but the
    --  object may not be attached at all if it is Finalize_Storage_Only
 
    procedure Detach_From_Final_List (Obj : in out Finalizable) is
@@ -273,6 +273,13 @@ package body System.Finalization_Implementation is
          SSL.Lock_Task.all;
          Obj.Next.Prev := Obj.Prev;
          Obj.Prev.Next := Obj.Next;
+
+         --  Reset the pointers so that a new finalization of the same object
+         --  has no effect on the finalization list.
+
+         Obj.Next := null;
+         Obj.Prev := null;
+
          SSL.Unlock_Task.all;
       end if;