bugfix imfile: memory leak upon shutdown (cosmetic)

When rsyslog shuts down and imfile is inside a change polling loop,
it does not properly free memory returned by glob(). This is a cosmetic
bug as the process terminates within the next few milliseconds. However,
it causes memory analyzer reports and thus makes CI fail.
This commit is contained in:
Rainer Gerhards 2018-07-24 15:06:59 +02:00
parent 5c90771758
commit 5458f1ce6d

View File

@ -753,9 +753,11 @@ poll_tree(fs_edge_t *const chld)
{
struct stat fileInfo;
glob_t files;
int need_globfree = 0;
DBGPRINTF("poll_tree: chld %p, name '%s', path: %s\n", chld, chld->name, chld->path);
detect_updates(chld);
const int ret = glob((char*)chld->path, runModConf->sortFiles|GLOB_BRACE, NULL, &files);
need_globfree = 1;
DBGPRINTF("poll_tree: glob returned %d\n", ret);
if(ret == 0) {
DBGPRINTF("poll_tree: processing %d files\n", (int) files.gl_pathc);
@ -788,12 +790,15 @@ poll_tree(fs_edge_t *const chld)
}
act_obj_add(chld, file, is_file, fileInfo.st_ino);
}
globfree(&files);
}
poll_active_files(chld);
done: return;
done:
if(need_globfree) {
globfree(&files);
}
return;
}
#ifdef HAVE_INOTIFY_INIT // TODO: shouldn't we use that in polling as well?