From 538e7566185ccd4f6accd55fcb55644c0223d82f Mon Sep 17 00:00:00 2001 From: rbuj Date: Thu, 14 Mar 2019 08:52:34 +0100 Subject: Fix use-after-free clang warning battstat_applet.c:755:3: warning: Use of memory after it is freed static_global_teardown (battstat); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ stickynotes.c:674:24: warning: Use of memory after it is freed stickynotes->notes = g_list_remove(stickynotes->notes, note); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- stickynotes/stickynotes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'stickynotes') diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c index f71577b0..dd0a4fc5 100644 --- a/stickynotes/stickynotes.c +++ b/stickynotes/stickynotes.c @@ -668,10 +668,12 @@ void stickynotes_remove(StickyNote *note) if (stickynote_get_empty(note) || !g_settings_get_boolean (stickynotes->settings, "confirm-deletion") || gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { - stickynote_free(note); /* Remove the note from the linked-list of all notes */ - stickynotes->notes = g_list_remove(stickynotes->notes, note); + stickynotes->notes = g_list_remove_all (stickynotes->notes, note); + + /* Destroy the note */ + stickynote_free (note); /* Update tooltips */ stickynotes_applet_update_tooltips(); -- cgit v1.2.1