diff options
| author | Saverio Miroddi <[email protected]> | 2026-07-21 13:09:53 +0200 |
|---|---|---|
| committer | Victor Kareh <[email protected]> | 2026-07-30 22:03:47 +0000 |
| commit | 3ce6b85a04d5dacf27a228e002a4f301fc88abfd (patch) | |
| tree | 151702bb185cd1d6df8fd90cb9d52948dc06bc58 /src | |
| parent | d3a424b438c4df3e464b652f71ee3f57f5e2bbd2 (diff) | |
| download | mate-notification-daemon-3ce6b85a04d5dacf27a228e002a4f301fc88abfd.tar.bz2 mate-notification-daemon-3ce6b85a04d5dacf27a228e002a4f301fc88abfd.tar.xz | |
g_variant_dup_strv() allocates a vector and duplicates every string. The
generated completion helper copies that vector into the outgoing GVariant,
leaving the duplicated input unowned. AddressSanitizer reports 360 direct
bytes and 420 indirect bytes leaked after five calls.
Pass the constant capability list directly to the helper instead. This
avoids the temporary allocations while leaving the returned capabilities
unchanged.
Signed-off-by: Saverio Miroddi <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/daemon/daemon.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 4ff9ea9..7f4516f 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -1943,25 +1943,22 @@ static gboolean notify_daemon_close_notification_handler(NotifyDaemonNotificatio static gboolean notify_daemon_get_capabilities( NotifyDaemonNotifications *object, GDBusMethodInvocation *invocation) { - GVariantBuilder *builder; - GVariant *value; - - builder = g_variant_builder_new (G_VARIANT_TYPE ("as")); - g_variant_builder_add (builder, "s", "actions"); - g_variant_builder_add (builder, "s", "action-icons"); - g_variant_builder_add (builder, "s", "body"); - g_variant_builder_add (builder, "s", "body-hyperlinks"); - g_variant_builder_add (builder, "s", "body-markup"); - g_variant_builder_add (builder, "s", "icon-static"); - g_variant_builder_add (builder, "s", "sound"); - g_variant_builder_add (builder, "s", "persistence"); - value = g_variant_new ("as", builder); - g_variant_builder_unref (builder); + static const gchar *const capabilities[] = { + "actions", + "action-icons", + "body", + "body-hyperlinks", + "body-markup", + "icon-static", + "sound", + "persistence", + NULL + }; + notify_daemon_notifications_complete_get_capabilities ( object, invocation, - (const gchar* const *)g_variant_dup_strv (value, NULL)); - g_variant_unref (value); + capabilities); return TRUE; } |
