plugins: pidfile: Fix memory leak in pidfile_callback()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-02-29 16:40:06 +01:00
parent 27c839bc92
commit 1176961e7b
+4 -4
View File
@@ -176,8 +176,7 @@ static void pidfile_callback(void *arg, int fd, int events)
sz = read(fd, buf, buflen - 1);
if (sz <= 0) {
_pe("invalid inotify event");
free(buf);
return;
goto done;
}
buf[sz] = 0;
_d("pidfile: Read %zd bytes, processing ...", sz);
@@ -207,8 +206,7 @@ static void pidfile_callback(void *arg, int fd, int events)
path = malloc(plen);
if (!path) {
_pe("Failed allocating path buffer for watcher");
free(buf);
return;
goto done;
}
snprintf(path, plen, "%s/%s", wde->path, ev->name);
_d("pidfile: path is %s", path);
@@ -247,6 +245,8 @@ static void pidfile_callback(void *arg, int fd, int events)
if (ev->mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO))
update_conds(ev->name, ev->mask);
}
done:
free(buf);
}
/*