diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-24 19:09:19 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-04-05 19:58:53 -0400 |
commit | c84a94883161073239c35d181e25823ff0454f68 (patch) | |
tree | 64c6fbf807493f3d878fa53113ba857116de7393 /src/tmpfiles/tmpfiles.c | |
parent | b92bea5d2a9481de69bb627a7b442a9f58fca43d (diff) |
Add _cleanup_globfree_
Fixes a memleak in error path in exec_context_load_environment.
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 51827f01af..5d32bd1975 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -601,12 +601,12 @@ static int recursive_relabel(Item *i, const char *path) { static int glob_item(Item *i, int (*action)(Item *, const char *)) { int r = 0, k; - glob_t g = {}; + glob_t _cleanup_globfree_ g = {}; char **fn; errno = 0; - if ((k = glob(i->path, GLOB_NOSORT|GLOB_BRACE, NULL, &g)) != 0) { - + k = glob(i->path, GLOB_NOSORT|GLOB_BRACE, NULL, &g); + if (k != 0) if (k != GLOB_NOMATCH) { if (errno > 0) errno = EIO; @@ -614,13 +614,13 @@ static int glob_item(Item *i, int (*action)(Item *, const char *)) { log_error("glob(%s) failed: %m", i->path); return -errno; } - } - STRV_FOREACH(fn, g.gl_pathv) - if ((k = action(i, *fn)) < 0) + STRV_FOREACH(fn, g.gl_pathv) { + k = action(i, *fn); + if (k < 0) r = k; + } - globfree(&g); return r; } |