Fix CID 1491362: dereference after null check.
authorwwp <subscript@free.fr>
Wed, 29 Sep 2021 10:43:22 +0000 (12:43 +0200)
committerwwp <subscript@free.fr>
Wed, 29 Sep 2021 10:43:22 +0000 (12:43 +0200)
Fix CID 1491278: (neutral) use after free (but still better to disable callbacks before freeing).

src/plugins/managesieve/sieve_editor.c

index 3ed1022012fc557b19a123517664e93b512881a1..3c99e0c39519b68548ea9bac84902d8428f3be12 100644 (file)
@@ -164,7 +164,7 @@ static void sieve_editor_append_status(SieveEditorPage *page,
        GtkLabel *label = GTK_LABEL(page->status_text);
        const gchar *prev_status = gtk_label_get_text(label);
        const gchar *sep = prev_status && prev_status[0] ? "\n" : "";
-       gchar *status = g_strconcat(prev_status, sep, new_status, NULL);
+       gchar *status = g_strconcat(prev_status ? prev_status : "", sep, new_status, NULL);
        gtk_label_set_text(label, status);
        g_free(status);
 }
@@ -422,8 +422,8 @@ static void sieve_editor_destroy(SieveEditorPage *page)
 void sieve_editor_close(SieveEditorPage *page)
 {
        editors = g_slist_remove(editors, (gconstpointer)page);
-       sieve_editor_destroy(page);
        sieve_sessions_discard_callbacks(page);
+       sieve_editor_destroy(page);
 }
 
 static gboolean sieve_editor_confirm_close(SieveEditorPage *page)