s-finimp.adb (Detach_From_Final_List): make this procedure idempotent since it is...
authorCyrille Comar <comar@adacore.com>
Tue, 14 Aug 2007 08:49:45 +0000 (10:49 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 14 Aug 2007 08:49:45 +0000 (10:49 +0200)
2007-08-14  Cyrille Comar  <comar@adacore.com>

* 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.

From-SVN: r127462

gcc/ada/s-finimp.adb

index 4f6c4c165e466ff1eb5d5c09bdd5dd35608d4c9a..4ed7c6ce1e889870758f0796e956144c35ce53ee 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;