Skip to content

Commit

Permalink
V503-022 Prevent access to dangling pointers
Browse files Browse the repository at this point in the history
Prevent access to dangling pointers which could occur when
the Buffer_View might want to refresh itself whilst the MDI
is being destroyed.

Change-Id: I61e027e8364785beecc8e0613aa1895647da9a4d
  • Loading branch information
setton committed May 10, 2022
1 parent 488b038 commit 389bae4
Show file tree
Hide file tree
Showing 7 changed files with 1,701 additions and 1 deletion.
1 change: 1 addition & 0 deletions testsuite/tests/V503-022.buffer_view_finalization/a.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions testsuite/tests/V503-022.buffer_view_finalization/p.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project p is
end p;
1,684 changes: 1,684 additions & 0 deletions testsuite/tests/V503-022.buffer_view_finalization/perspectives6.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions testsuite/tests/V503-022.buffer_view_finalization/test.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cp perspectives6.xml $GNATSTUDIO_HOME/.gnatstudio/
$GNATSTUDIO -Pp a.adb --load=python:test.py
8 changes: 8 additions & 0 deletions testsuite/tests/V503-022.buffer_view_finalization/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from gs_utils.internal.utils import run_test_driver


@run_test_driver
def driver():
# The goal of this test is to exit immediately; this should show a
# memory corruption under valgrind if failing.
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: 'V503-022.buffer_view_finalization'
4 changes: 3 additions & 1 deletion views/src/buffer_views.adb
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,9 @@ package body Buffer_Views is
pragma Unreferenced (Column);

begin
if Get_MDI (V.Kernel) = null then
if V.Kernel.Is_In_Destruction
or else Get_MDI (V.Kernel) = null
then
return;
end if;

Expand Down

0 comments on commit 389bae4

Please sign in to comment.