Skip to content

Commit

Permalink
Fix some memory leaks
Browse files Browse the repository at this point in the history
g_build_filename() always transfer full
Add auto cleanup for Settings implementation

Signed-off-by: Hubert Figuière <[email protected]>
  • Loading branch information
hfiguiere authored and GeorgesStavracas committed Oct 6, 2024
1 parent 53bbf4b commit d1bc22f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ G_DEFINE_TYPE_WITH_CODE (Settings, settings, XDP_DBUS_TYPE_SETTINGS_SKELETON,
G_IMPLEMENT_INTERFACE (XDP_DBUS_TYPE_SETTINGS,
settings_iface_init));

G_DEFINE_AUTOPTR_CLEANUP_FUNC (Settings, g_object_unref)

static gboolean
settings_handle_read_all (XdpDbusSettings *object,
GDBusMethodInvocation *invocation,
Expand Down Expand Up @@ -217,7 +219,7 @@ GDBusInterfaceSkeleton *
settings_create (GDBusConnection *connection,
GPtrArray *implementations)
{
Settings *settings;
g_autoptr(Settings) settings = NULL;
g_autoptr(GError) error = NULL;
int i;
int n_impls_tmp;
Expand Down Expand Up @@ -255,5 +257,5 @@ settings_create (GDBusConnection *connection,
return NULL;
}

return G_DBUS_INTERFACE_SKELETON (settings);
return G_DBUS_INTERFACE_SKELETON (g_steal_pointer (&settings));
}
2 changes: 1 addition & 1 deletion src/xdp-app-info-flatpak.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ load_bwrap_info (const char *instance,
g_autoptr(JsonNode) root = NULL;
g_autofree char *data = NULL;
gsize len;
char *path;
g_autofree char *path = NULL;

g_return_val_if_fail (instance != NULL, 0);

Expand Down

0 comments on commit d1bc22f

Please sign in to comment.