From 438024c6265c1717832ef977e8ab291725903610 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Thu, 14 Dec 2023 23:54:07 +0100 Subject: [PATCH] Fix use-after-free in SNI gtk_icon_theme_load_icon returns a pixbuf which is not owned by us, and therefore g_free shouldn't be called. When reloading an icon, this pixbuf was reused by the icon theme even though we just free'd it. Fixes: https://github.com/scorpion-26/gBar/issues/74 --- src/SNI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SNI.cpp b/src/SNI.cpp index 1525177..43c2bb8 100644 --- a/src/SNI.cpp +++ b/src/SNI.cpp @@ -279,7 +279,7 @@ namespace SNI LOG("SNI: " << name << " vanished!"); g_bus_unwatch_name(it->watcherID); g_dbus_connection_signal_unsubscribe(dbusConnection, it->propertyChangeWatcherID); - g_free(it->pixbuf); + g_object_unref(it->pixbuf); items.erase(it); InvalidateWidget(); return; @@ -337,7 +337,7 @@ namespace SNI { g_bus_unwatch_name(it->watcherID); g_dbus_connection_signal_unsubscribe(dbusConnection, it->propertyChangeWatcherID); - g_free(it->pixbuf); + g_object_unref(it->pixbuf); items.erase(it); } else