changeset 37400:2ac65f4d70e5

(delete_kboard): Prevent a dangling reference from current_kboard to KB, which is freed.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 19 Apr 2001 13:00:01 +0000
parents 9e11cb3d60f1
children 0e96cdc29f68
files src/keyboard.c
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Thu Apr 19 12:47:59 2001 +0000
+++ b/src/keyboard.c	Thu Apr 19 13:00:01 2001 +0000
@@ -10013,19 +10013,33 @@
 }
 
 #ifdef MULTI_KBOARD
+
+/* Free KB and memory referenced from it.  */
+
 void
 delete_kboard (kb)
-  KBOARD *kb;
+     KBOARD *kb;
 {
   KBOARD **kbp;
+  
   for (kbp = &all_kboards; *kbp != kb; kbp = &(*kbp)->next_kboard)
     if (*kbp == NULL)
       abort ();
   *kbp = kb->next_kboard;
+
+  /* Prevent a dangling reference to KB.  */
+  if (kb == current_kboard)
+    {
+      current_kboard = SELECTED_FRAME ()->kboard;
+      if (current_kboard == kb)
+	abort ();
+    }
+  
   wipe_kboard (kb);
   xfree (kb);
 }
-#endif
+
+#endif /* MULTI_KBOARD */
 
 void
 init_keyboard ()