[gimp/gimp-2-10] libgimpbase: fix memory leak in gimp_installation_directory().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] libgimpbase: fix memory leak in gimp_installation_directory().
- Date: Tue, 19 Jan 2021 11:16:18 +0000 (UTC)
commit 603cc117b9d4ac288081515292dd966f8ed8a047
Author: Jehan <jehan girinstud io>
Date: Tue Jan 19 12:04:53 2021 +0100
libgimpbase: fix memory leak in gimp_installation_directory().
Argh I should have properly reviewed !392 (commit c264f0b705).
It was leaking the return value of a g_path_get_basename().
(cherry picked from commit 1873f0d65cccb6b639f1038f2981ff8667c44464)
libgimpbase/gimpenv.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index 26844aa5ac..10696a5140 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -400,6 +400,7 @@ gimp_installation_directory (void)
NSAutoreleasePool *pool;
NSString *resource_path;
gchar *basename;
+ gchar *basepath;
gchar *dirname;
pool = [[NSAutoreleasePool alloc] init];
@@ -407,7 +408,8 @@ gimp_installation_directory (void)
resource_path = [[NSBundle mainBundle] resourcePath];
basename = g_path_get_basename ([resource_path UTF8String]);
- dirname = g_path_get_dirname ([resource_path UTF8String]);
+ basepath = g_path_get_dirname ([resource_path UTF8String]);
+ dirname = g_path_get_basename (basepath);
if (! strcmp (basename, ".libs"))
{
@@ -421,13 +423,13 @@ gimp_installation_directory (void)
* path is the directory which contains the executable
*/
- toplevel = g_strdup (dirname);
+ toplevel = g_strdup (basepath);
}
else if (! strcmp (basename, "plug-ins"))
{
/* same for plug-ins, go three levels up from prefix/lib/gimp/x.y */
- gchar *tmp = g_path_get_dirname (dirname);
+ gchar *tmp = g_path_get_dirname (basepath);
gchar *tmp2 = g_path_get_dirname (tmp);
toplevel = g_path_get_dirname (tmp2);
@@ -435,11 +437,11 @@ gimp_installation_directory (void)
g_free (tmp);
g_free (tmp2);
}
- else if (! strcmp (g_path_get_basename (dirname), "plug-ins"))
+ else if (! strcmp (dirname, "plug-ins"))
{
/* same for plug-ins in subdirectory, go three levels up from prefix/lib/gimp/x.y */
- gchar *tmp = g_path_get_dirname (dirname);
+ gchar *tmp = g_path_get_dirname (basepath);
gchar *tmp2 = g_path_get_dirname (tmp);
gchar *tmp3 = g_path_get_dirname (tmp2);
@@ -457,6 +459,7 @@ gimp_installation_directory (void)
}
g_free (basename);
+ g_free (basepath);
g_free (dirname);
[pool drain];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]