Skip to content

Commit d1bc22f

Browse files
hfiguiereGeorgesStavracas
authored andcommitted
Fix some memory leaks
g_build_filename() always transfer full Add auto cleanup for Settings implementation Signed-off-by: Hubert Figuière <[email protected]>
1 parent 53bbf4b commit d1bc22f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/settings.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ G_DEFINE_TYPE_WITH_CODE (Settings, settings, XDP_DBUS_TYPE_SETTINGS_SKELETON,
5656
G_IMPLEMENT_INTERFACE (XDP_DBUS_TYPE_SETTINGS,
5757
settings_iface_init));
5858

59+
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Settings, g_object_unref)
60+
5961
static gboolean
6062
settings_handle_read_all (XdpDbusSettings *object,
6163
GDBusMethodInvocation *invocation,
@@ -217,7 +219,7 @@ GDBusInterfaceSkeleton *
217219
settings_create (GDBusConnection *connection,
218220
GPtrArray *implementations)
219221
{
220-
Settings *settings;
222+
g_autoptr(Settings) settings = NULL;
221223
g_autoptr(GError) error = NULL;
222224
int i;
223225
int n_impls_tmp;
@@ -255,5 +257,5 @@ settings_create (GDBusConnection *connection,
255257
return NULL;
256258
}
257259

258-
return G_DBUS_INTERFACE_SKELETON (settings);
260+
return G_DBUS_INTERFACE_SKELETON (g_steal_pointer (&settings));
259261
}

src/xdp-app-info-flatpak.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ load_bwrap_info (const char *instance,
500500
g_autoptr(JsonNode) root = NULL;
501501
g_autofree char *data = NULL;
502502
gsize len;
503-
char *path;
503+
g_autofree char *path = NULL;
504504

505505
g_return_val_if_fail (instance != NULL, 0);
506506

0 commit comments

Comments
 (0)