From 65b4f270547e6618baa110619126dcfd3d957268 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 3 Sep 2015 01:15:23 +0000 Subject: [PATCH] Don't leak 'var'. Reported by: clang static analyzer --- usr.sbin/makefs/mtree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c index 9d396d1a5ecb..8a687bfd5534 100644 --- a/usr.sbin/makefs/mtree.c +++ b/usr.sbin/makefs/mtree.c @@ -181,7 +181,7 @@ static char * mtree_resolve(const char *spec, int *istemp) { struct sbuf *sb; - char *res, *var; + char *res, *var = NULL; const char *base, *p, *v; size_t len; int c, error, quoted, subst; @@ -284,8 +284,10 @@ mtree_resolve(const char *spec, int *istemp) free(res); } free(var); + var = NULL; } + free(var); sbuf_finish(sb); res = (error == 0) ? strdup(sbuf_data(sb)) : NULL; sbuf_delete(sb);