From 41b730aa3a09e43875b6d3b38f997ad522491b5b Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 5 Oct 2023 23:01:21 +0300
Subject: [PATCH 29/29] gtk: Avoid double diplodlg free

Reported by mortmann

See osdn #48807

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

diff --git a/client/gui-gtk-2.0/diplodlg.c b/client/gui-gtk-2.0/diplodlg.c
index e4470b81cd..06fa8d8221 100644
--- a/client/gui-gtk-2.0/diplodlg.c
+++ b/client/gui-gtk-2.0/diplodlg.c
@@ -566,9 +566,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-3.0/diplodlg.c b/client/gui-gtk-3.0/diplodlg.c
index b142da7de6..0a5fc35b42 100644
--- a/client/gui-gtk-3.0/diplodlg.c
+++ b/client/gui-gtk-3.0/diplodlg.c
@@ -566,9 +566,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-3.22/diplodlg.c b/client/gui-gtk-3.22/diplodlg.c
index e1b1b0f06a..0f308cc143 100644
--- a/client/gui-gtk-3.22/diplodlg.c
+++ b/client/gui-gtk-3.22/diplodlg.c
@@ -564,9 +564,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);
-- 
2.40.1