From 199743d5ae8e89fa4065e544d998ebaeab1c1cd6 Mon Sep 17 00:00:00 2001 From: Werner Hoch Date: Sun, 15 Jun 2008 09:51:17 +0200 Subject: [PATCH] libgeda: fix memory leak introduced with the last commit. The function g_path_get_basename returns a newly allocated string. This string has to be freed after usage. Thanks to Peter C. for the hint. --- libgeda/src/o_picture.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libgeda/src/o_picture.c b/libgeda/src/o_picture.c index 964145937..c404dfb5d 100644 --- a/libgeda/src/o_picture.c +++ b/libgeda/src/o_picture.c @@ -916,6 +916,7 @@ void o_picture_embed (TOPLEVEL *toplevel, OBJECT *object) { GError *err = NULL; GdkPixbuf *pixbuf; + gchar *filename; /* Free any existing embedded data */ g_free (object->picture->file_content); @@ -952,8 +953,9 @@ void o_picture_embed (TOPLEVEL *toplevel, OBJECT *object) object->picture->original_picture = pixbuf; - s_log_message (_("Picture [%s] has been embedded\n"), - g_path_get_basename(object->picture->filename)); + filename = g_path_get_basename(object->picture->filename); + s_log_message (_("Picture [%s] has been embedded\n"), filename); + g_free(filename); } @@ -970,6 +972,7 @@ void o_picture_unembed (TOPLEVEL *toplevel, OBJECT *object) { GError *err = NULL; GdkPixbuf *pixbuf; + gchar *filename; pixbuf = gdk_pixbuf_new_from_file (object->picture->filename, &err); if (err != NULL) { @@ -990,8 +993,9 @@ void o_picture_unembed (TOPLEVEL *toplevel, OBJECT *object) object->picture->file_length = 0; object->picture->embedded = 0; - s_log_message (_("Picture [%s] has been unembedded\n"), - g_path_get_basename(object->picture->filename)); + filename = g_path_get_basename(object->picture->filename); + s_log_message (_("Picture [%s] has been unembedded\n"), filename); + g_free(filename); } -- 2.11.4.GIT