summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-03-10 19:24:18 +0100
committerJan Pokorný <jpokorny@redhat.com>2015-03-16 22:39:52 +0100
commit19d056812c319805e86ee4f2172951d59f6640ee (patch)
treea5c941fdf8e313c5145c037929c6136efdaecc8d
parent3075b6302eba607945e6524ca2d76cc78b9322b1 (diff)
downloadclufter-19d056812c319805e86ee4f2172951d59f6640ee.tar.gz
clufter-19d056812c319805e86ee4f2172951d59f6640ee.tar.xz
clufter-19d056812c319805e86ee4f2172951d59f6640ee.zip
ccs-flatten/resrules.c: track success of glob + cleanup afterwards
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--__root__/ccs-flatten/resrules.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/__root__/ccs-flatten/resrules.c b/__root__/ccs-flatten/resrules.c
index 716f88e..81a37d6 100644
--- a/__root__/ccs-flatten/resrules.c
+++ b/__root__/ccs-flatten/resrules.c
@@ -919,7 +919,7 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules,
pathT pathbuf1 = "/proc/self/exe", pathbuf2 = "";
pathT *path1 = &pathbuf1, *path2 = &pathbuf2;
struct stat st_buf;
- glob_t globbuf;
+ glob_t globbuf, *globbuf_ptr = &globbuf;
int i;
/* jump to "convenient fallback" if there are no _own_ metadata present
@@ -932,13 +932,14 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules,
#endif
if (!(
(dir = opendir(rpath))
- && (!rawmetadata || !glob(path, GLOB_NOSORT, NULL, &globbuf))
+ && (!rawmetadata || !glob(path, GLOB_NOSORT, NULL, globbuf_ptr))
)) {
/* convenient fallback for local/test deployment, rawmetadata only */
if (dir)
closedir(dir);
if (!rawmetadata)
return -1;
+ globbuf_ptr = NULL;
for (i = 0; i < 8; i++) {
errno = 0;
if (readlink(*path1, *path2, sizeof(*path2)/sizeof(**path2))
@@ -1002,6 +1003,9 @@ load_resource_rules(const char *rpath, resource_rule_t ** rules,
load_resource_rulefile(path, rules, rawmetadata);
}
+ if (rawmetadata && globbuf_ptr)
+ globfree(globbuf_ptr);
+
closedir(dir);
return 0;