Skip to content

Commit

Permalink
add missing free()
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kress committed Jul 18, 2023
1 parent 917b6b5 commit ef0f7a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion metalog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ maxtime = 2592000
# Number of archive files per directory
maxfiles = 5

# directory with more config files to load; files names must end ending with ".conf"
# directory with more config files to load; files names must end with ".conf"
#configdir = /etc/metalog.d

# Permissions for log directories. 0750 allows group to read logs. 0700 is default.
Expand Down
11 changes: 6 additions & 5 deletions src/metalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ static int parseLine(char * const line, ConfigBlock **cur_block,
static int configParser(const char * const file)
{
char line[LINE_MAX];
FILE *fp;
char *file_path = NULL;
FILE *fp = NULL;
pcre2_code *re_newblock;
pcre2_code *re_newstmt;
pcre2_code *re_comment;
Expand Down Expand Up @@ -474,8 +473,6 @@ static int configParser(const char * const file)

/* read all config files of an eventually configured directory */
if (config_dir != NULL) {
FILE *fp2;
char *p = NULL;
DIR *dp;
struct dirent *ep;

Expand All @@ -487,6 +484,10 @@ static int configParser(const char * const file)

/* config file names must end with ".conf" */
while ((ep = readdir(dp)) != NULL) {
FILE *fp2 = NULL;
char *p = NULL;
char *file_path = NULL;

p = strchr(ep->d_name, (int) '.');
if (p == NULL || !strstr(p, ".conf")) {
continue;
Expand All @@ -500,6 +501,7 @@ static int configParser(const char * const file)
if ((fp2 = fopen(file_path, "r")) == NULL) {
warnp("Can't open the config file %s", file_path);
retcode = -1;
free(file_path);
goto rtn;
}

Expand All @@ -512,7 +514,6 @@ static int configParser(const char * const file)
}

free(file_path);
file_path = NULL;
fclose(fp2);
}
closedir(dp);
Expand Down

0 comments on commit ef0f7a0

Please sign in to comment.