Skip to content

Commit 389bae4

Browse files
committed
V503-022 Prevent access to dangling pointers
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
1 parent 488b038 commit 389bae4

File tree

7 files changed

+1701
-1
lines changed

7 files changed

+1701
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project p is
2+
end p;

testsuite/tests/V503-022.buffer_view_finalization/perspectives6.xml

Lines changed: 1684 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cp perspectives6.xml $GNATSTUDIO_HOME/.gnatstudio/
2+
$GNATSTUDIO -Pp a.adb --load=python:test.py
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from gs_utils.internal.utils import run_test_driver
2+
3+
4+
@run_test_driver
5+
def driver():
6+
# The goal of this test is to exit immediately; this should show a
7+
# memory corruption under valgrind if failing.
8+
pass
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'V503-022.buffer_view_finalization'

views/src/buffer_views.adb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,9 @@ package body Buffer_Views is
650650
pragma Unreferenced (Column);
651651

652652
begin
653-
if Get_MDI (V.Kernel) = null then
653+
if V.Kernel.Is_In_Destruction
654+
or else Get_MDI (V.Kernel) = null
655+
then
654656
return;
655657
end if;
656658

0 commit comments

Comments
 (0)