Skip to content

Commit c770e7b

Browse files
swickGeorgesStavracas
authored andcommitted
notification: Do not leak the notification GVariantBuilder
By stealing the builder to end the construction, parser_data_free didn't get a chance the free the builder. End construction in the parser_data implementation and own the resulting GVariant. The parse_notification_finish function can then just steal that struct member instead.
1 parent 4e34d92 commit c770e7b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libportal/notification.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ typedef struct {
139139
GUnixFDList *fd_list;
140140
GVariantBuilder *builder;
141141
gsize hold_count;
142+
GVariant *data;
142143
} ParserData;
143144

144145
static ParserData*
@@ -168,7 +169,10 @@ parser_data_release (ParserData *data)
168169
data->hold_count--;
169170

170171
if (data->hold_count == 0)
171-
g_variant_builder_close (data->builder);
172+
{
173+
g_variant_builder_close (data->builder);
174+
data->data = g_variant_ref_sink (g_variant_builder_end (data->builder));
175+
}
172176

173177
return data->hold_count == 0;
174178
}
@@ -180,6 +184,7 @@ parser_data_free (gpointer user_data)
180184

181185
g_clear_object (&data->fd_list);
182186
g_clear_pointer (&data->builder, g_variant_builder_unref);
187+
g_clear_pointer (&data->data, g_variant_unref);
183188

184189
g_free (data);
185190
}
@@ -568,7 +573,7 @@ parse_notification_finish (GAsyncResult *result,
568573
if (fd_list)
569574
*fd_list = g_steal_pointer (&data->fd_list);
570575

571-
return g_variant_ref_sink (g_variant_builder_end (g_steal_pointer (&data->builder)));
576+
return g_steal_pointer (&data->data);
572577
}
573578

574579
static void

0 commit comments

Comments
 (0)