From 621529c12eb1e55c70d55b719c244c12c6b7b9e4 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 5 Oct 2023 23:02:42 +0300
Subject: [PATCH 42/42] gtk: Avoid double diplodlg free

Reported by mortmann

See osdn #48807

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-3.22/diplodlg.c | 3 ++-
 client/gui-gtk-4.0/diplodlg.c  | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/client/gui-gtk-3.22/diplodlg.c b/client/gui-gtk-3.22/diplodlg.c
index a70ddc83a7..7302e509bc 100644
--- a/client/gui-gtk-3.22/diplodlg.c
+++ b/client/gui-gtk-3.22/diplodlg.c
@@ -625,9 +625,10 @@ static void diplomacy_main_response(struct gui_dialog *dlg, int response,
 static void diplomacy_destroy(struct Diplomacy_dialog* pdialog)
 {
   if (NULL != pdialog->dialog) {
-    /* pdialog->dialog may be NULL if the tab have been destroyed
+    /* pdialog->dialog may be NULL if the tab has been destroyed
      * by an other way. */
     gui_dialog_destroy(pdialog->dialog);
+    pdialog->dialog = NULL;
   }
   dialog_list_remove(dialog_list, pdialog);
   free(pdialog);
diff --git a/client/gui-gtk-4.0/diplodlg.c b/client/gui-gtk-4.0/diplodlg.c
index 4d9aab11aa..97ed5a5073 100644
--- a/client/gui-gtk-4.0/diplodlg.c
+++ b/client/gui-gtk-4.0/diplodlg.c
@@ -692,12 +692,13 @@ static void diplomacy_main_response(struct gui_dialog *dlg, int response,
 /************************************************************************//**
   Destroy diplomacy dialog
 ****************************************************************************/
-static void diplomacy_destroy(struct Diplomacy_dialog* pdialog)
+static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
 {
   if (NULL != pdialog->dialog) {
-    /* pdialog->dialog may be NULL if the tab have been destroyed
+    /* pdialog->dialog may be NULL if the tab has been destroyed
      * by an other way. */
     gui_dialog_destroy(pdialog->dialog);
+    pdialog->dialog = NULL;
   }
   dialog_list_remove(dialog_list, pdialog);
   free(pdialog);
-- 
2.40.1