[gimp] core: minor memleak fixes
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] core: minor memleak fixes
- Date: Sun, 23 May 2021 15:36:14 +0000 (UTC)
commit f8320ce5356334dc2d2a43b5524a0993865669a3
Author: Stanislav Grinkov <43956-stanislavgrinkov users noreply gitlab gnome org>
Date: Sat May 8 23:20:46 2021 +0600
core: minor memleak fixes
Fix several memory leaks when uri obtained by g_file_get_uri ()
was not g_free'd ().
app/file/file-utils.c | 2 ++
app/gimp-update.c | 14 +++++++++++---
plug-ins/file-tiff/file-tiff-load.c | 31 ++++++++++++++++++++++++-------
3 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/app/file/file-utils.c b/app/file/file-utils.c
index d9d862eed4..093ae98ae0 100644
--- a/app/file/file-utils.c
+++ b/app/file/file-utils.c
@@ -181,6 +181,8 @@ file_utils_load_thumbnail (GFile *file)
thumbnail = gimp_thumbnail_new ();
gimp_thumbnail_set_uri (thumbnail, uri);
+ g_free (uri);
+
pixbuf = gimp_thumbnail_load_thumb (thumbnail,
(GimpThumbSize) GIMP_THUMBNAIL_SIZE_NORMAL,
NULL);
diff --git a/app/gimp-update.c b/app/gimp-update.c
index 7791bf61c3..66b2ad82b8 100644
--- a/app/gimp-update.c
+++ b/app/gimp-update.c
@@ -337,8 +337,12 @@ gimp_check_updates_callback (GObject *source,
parser = json_parser_new ();
if (! json_parser_load_from_data (parser, file_contents, file_length, &error))
{
+ gchar *uri = g_file_get_uri (G_FILE (source));
+
g_printerr ("%s: parsing of %s failed: %s\n", G_STRFUNC,
- g_file_get_uri (G_FILE (source)), error->message);
+ uri, error->message);
+
+ g_free (uri);
g_free (file_contents);
g_clear_object (&parser);
g_clear_error (&error);
@@ -387,8 +391,12 @@ gimp_check_updates_callback (GObject *source,
}
else
{
- g_printerr("%s: loading of %s failed: %s\n", G_STRFUNC,
- g_file_get_uri (G_FILE (source)), error->message);
+ gchar *uri = g_file_get_uri (G_FILE (source));
+
+ g_printerr ("%s: loading of %s failed: %s\n", G_STRFUNC,
+ uri, error->message);
+
+ g_free (uri);
g_clear_error (&error);
}
}
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 7038ceaba7..f0abf7711c 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -977,22 +977,39 @@ load_image (GFile *file,
if (pages.target == GIMP_PAGE_SELECTOR_TARGET_IMAGES)
{
- gchar *fname = g_strdup_printf ("%s-%d", g_file_get_uri (file),
- ilayer);
+ gchar *uri;
+ gchar *fname;
+ GFile *new_file;
- gimp_image_set_file (*image, g_file_new_for_uri (fname));
+ uri = g_file_get_uri (file);
+ fname = g_strdup_printf ("%s-%d", uri, ilayer);
+ new_file = g_file_new_for_uri (fname);
+
+ gimp_image_set_file (*image, new_file);
+
+ g_free (uri);
g_free (fname);
+ g_object_unref (new_file);
images_list = g_list_prepend (images_list, *image);
}
else if (pages.o_pages != pages.n_pages)
{
- gchar *fname = g_strdup_printf (_("%s-%d-of-%d-pages"),
- g_file_get_uri (file),
- pages.n_pages, pages.o_pages);
+ gchar *uri;
+ gchar *fname;
+ GFile *new_file;
+
+ uri = g_file_get_uri (file);
+ fname = g_strdup_printf (_("%s-%d-of-%d-pages"),
+ uri,
+ pages.n_pages, pages.o_pages);
+ new_file = g_file_new_for_uri (fname);
+
+ gimp_image_set_file (*image, new_file);
- gimp_image_set_file (*image, g_file_new_for_uri (fname));
+ g_free (uri);
g_free (fname);
+ g_object_unref (new_file);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]