From e62c251a74b8625d80cf072d0b6cc3280d3e2eb1 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 21 Aug 2020 20:01:08 +0100 Subject: [PATCH] common/dir.c: fix double free --- src/common/dir.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/dir.c b/src/common/dir.c index 70eac58d..281ad4b6 100644 --- a/src/common/dir.c +++ b/src/common/dir.c @@ -77,7 +77,6 @@ static void build_theme_path(struct ctx *ctx, char *prefix, const char *path) char *find_dir(struct ctx *ctx) { - gchar **prefixes; char *debug = getenv("LABWC_DEBUG_DIR_CONFIG_AND_THEME"); for (int i = 0; ctx->dirs[i].path; i++) { @@ -94,13 +93,14 @@ char *find_dir(struct ctx *ctx) char *prefix = getenv(d.prefix); if (!prefix) continue; - prefixes = g_strsplit(prefix, ":", -1); + gchar **prefixes = g_strsplit(prefix, ":", -1); for (gchar **p = prefixes; *p; p++) { ctx->build_path_fn(ctx, *p, d.path); if (debug) info("%s", ctx->buf); if (isdir(ctx->buf)) { - goto out; + g_strfreev(prefixes); + return ctx->buf; } } g_strfreev(prefixes); @@ -109,8 +109,6 @@ char *find_dir(struct ctx *ctx) /* no directory was found */ ctx->buf[0] = '.'; ctx->buf[1] = '\0'; -out: - g_strfreev(prefixes); return ctx->buf; }