From f5a9bed34cb0fb8e8328a4dd7097905059dde231 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Mon, 24 Feb 2020 20:58:18 +0100 Subject: [PATCH] DISPLAY: Keep track of device using the display. Don't let someone close the display if they're not the one having opened it. --- display/display.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/display/display.c b/display/display.c index 22efa6e3..b3c5cd13 100644 --- a/display/display.c +++ b/display/display.c @@ -359,6 +359,7 @@ static long queue_interval; #define Y(P) (((P) - points) / xpixels) static int initialized = 0; +static void *device = NULL; /* Current display device. */ /* * global set by O/S display level to indicate "light pen tip switch activated" @@ -969,6 +970,7 @@ display_init(enum display_type type, int sf, void *dptr) initialized = 1; init_failed = 0; /* hey, we made it! */ + device = dptr; return 1; failed: @@ -982,10 +984,14 @@ display_close(void *dptr) if (!initialized) return; + if (device != dptr) + return; + free (points); ws_shutdown(); initialized = 0; + device = NULL; } void