--- a/libpurple/plugins.c Mon Mar 11 22:31:13 2024 -0500
+++ b/libpurple/plugins.c Tue Mar 12 02:16:52 2024 -0500
@@ -469,6 +469,7 @@
manager = purple_notification_manager_get_default();
purple_notification_manager_add(manager, notification);
+ g_clear_object(¬ification); --- a/libpurple/protocols/demo/purpledemoprotocolactions.c Mon Mar 11 22:31:13 2024 -0500
+++ b/libpurple/protocols/demo/purpledemoprotocolactions.c Tue Mar 12 02:16:52 2024 -0500
@@ -741,6 +741,7 @@
+ g_clear_object(¬ification); g_clear_object(&account);
@@ -780,6 +781,7 @@
+ g_clear_object(¬ification); g_clear_object(&account);
--- a/libpurple/purplenotificationmanager.h Mon Mar 11 22:31:13 2024 -0500
+++ b/libpurple/purplenotificationmanager.h Tue Mar 12 02:16:52 2024 -0500
@@ -78,7 +78,7 @@
* purple_notification_manager_add:
* @manager: The instance.
- * @notification: (transfer full): The [class@Notification] to add.
+ * @notification: (transfer none): The [class@Notification] to add. * Adds @notification into @manager.
--- a/libpurple/tests/test_notification_manager.c Mon Mar 11 22:31:13 2024 -0500
+++ b/libpurple/tests/test_notification_manager.c Tue Mar 12 02:16:52 2024 -0500
@@ -80,7 +80,7 @@
G_CALLBACK(test_purple_notification_manager_increment_cb),
- /* Create the notification and store it's id. */
+ /* Create the notification and store its id. */ notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC,
@@ -102,6 +102,9 @@
unread_count = purple_notification_manager_get_unread_count(manager);
g_assert_cmpint(unread_count, ==, 0);
+ /* After removal from the manager, nothing else should know about this. */ + g_assert_finalize_object(notification); /* Clean up the manager. */
g_clear_object(&manager);
@@ -120,10 +123,11 @@
purple_notification_manager_add(manager, notification);
purple_notification_manager_add(manager, notification);
- /* This will never get called as the double add outputs a g_warning()
- * that causes the test to fail. This is left to avoid a false positive
+ /* These will never get called as the double add outputs a g_warning() + * that causes the subprocess to exit. This is left to avoid a false + * positive in static analysis. + g_clear_object(¬ification); g_clear_object(&manager);
@@ -144,11 +148,6 @@
notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC,
- /* Add an additional reference because the manager takes one and the id
- * belongs to the notification. So without this, the first remove frees
- * the id which would cause an invalid read.
- g_object_ref(notification);
purple_notification_manager_add(manager, notification);
@@ -157,7 +156,7 @@
g_assert_cmpint(removed_called, ==, 1);
- g_clear_object(¬ification);
+ g_assert_finalize_object(notification); g_clear_object(&manager);
@@ -347,16 +346,12 @@
G_CALLBACK(test_purple_notification_manager_unread_count_cb),
- /* Create the notification and add a reference to it before we give our
- * original reference to the manager.
+ /* Create the notification. */ notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC,
- g_object_ref(notification);
purple_notification_manager_add(manager, notification);
/* Verify that the read and unread signals were not yet emitted. */
@@ -383,8 +378,8 @@
g_assert_cmpint(unread_count_called, ==, 3);
- g_clear_object(¬ification);
g_clear_object(&manager);
+ g_assert_finalize_object(notification); /******************************************************************************