summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2020-09-26 09:28:41 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2020-09-26 09:31:58 -0500
commit9bb769002cde06941f4ad1d2bb9231bbfd6a4a9d (patch)
tree3d8a3c4eb626255b8e8f43a93996eaabc14aa3c7
parent226d2dc0395b374fa7ec78fef38712197341eaee (diff)
downloadepiphany-mcatanzaro/#1352.tar.gz
prefs-appearance-page: Don't leak URIsmcatanzaro/#1352
Also, convert surrounding code to use autoptrs
-rw-r--r--src/preferences/prefs-appearance-page.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/preferences/prefs-appearance-page.c b/src/preferences/prefs-appearance-page.c
index 9af61f0bb..67c2f2d7e 100644
--- a/src/preferences/prefs-appearance-page.c
+++ b/src/preferences/prefs-appearance-page.c
@@ -152,25 +152,22 @@ css_file_created_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
- GFile *file = G_FILE (source);
- GFileOutputStream *stream;
- GError *error = NULL;
+ g_autoptr (GFile) file = G_FILE (source);
+ g_autoptr (GFileOutputStream) stream = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autofree char *uri = NULL;
stream = g_file_create_finish (file, result, &error);
if (stream == NULL && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
g_warning ("Failed to create %s: %s", g_file_get_path (file), error->message);
else {
- if (ephy_is_running_inside_flatpak ())
- ephy_open_uri_via_flatpak_portal (g_file_get_uri (file));
- else
+ if (ephy_is_running_inside_flatpak ()) {
+ uri = g_file_get_uri (file);
+ ephy_open_uri_via_flatpak_portal (uri);
+ } else {
ephy_file_launch_handler (file, gtk_get_current_event_time ());
+ }
}
-
- if (error != NULL)
- g_error_free (error);
- if (stream != NULL)
- g_object_unref (stream);
- g_object_unref (file);
}
static void
@@ -194,15 +191,18 @@ js_file_created_cb (GObject *source,
g_autoptr (GFile) file = G_FILE (source);
g_autoptr (GFileOutputStream) stream = NULL;
g_autoptr (GError) error = NULL;
+ g_autofree char *uri = NULL;
stream = g_file_create_finish (file, result, &error);
if (stream == NULL && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
g_warning ("Failed to create %s: %s", g_file_get_path (file), error->message);
else {
- if (ephy_is_running_inside_flatpak ())
- ephy_open_uri_via_flatpak_portal (g_file_get_uri (file));
- else
+ if (ephy_is_running_inside_flatpak ()) {
+ uri = g_file_get_uri (file);
+ ephy_open_uri_via_flatpak_portal (uri);
+ } else {
ephy_file_launch_handler (file, gtk_get_current_event_time ());
+ }
}
}