From a6ec2a75d7815d121d8c44cbdb0b3c028417aa4c Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sun, 29 Aug 2010 22:35:41 +0000 Subject: [PATCH] Fix a resource leak in the profile include support ticket: 6761 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24274 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/prof_parse.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c index 7f3d4c9d4..85bd91227 100644 --- a/src/util/profile/prof_parse.c +++ b/src/util/profile/prof_parse.c @@ -241,7 +241,7 @@ static errcode_t parse_include_dir(char *dirname, struct parse_state *state) { DIR *dir; char *pathname; - errcode_t retval; + errcode_t retval = 0; struct dirent *ent; dir = opendir(dirname); @@ -250,14 +250,17 @@ static errcode_t parse_include_dir(char *dirname, struct parse_state *state) while ((ent = readdir(dir)) != NULL) { if (!valid_name(ent->d_name)) continue; - if (asprintf(&pathname, "%s/%s", dirname, ent->d_name) < 0) - return ENOMEM; + if (asprintf(&pathname, "%s/%s", dirname, ent->d_name) < 0) { + retval = ENOMEM; + break; + } retval = parse_include_file(pathname, state); free(pathname); if (retval) - return retval; + break; } - return 0; + closedir(dir); + return retval; } static errcode_t parse_line(char *line, struct parse_state *state) -- 2.26.2