plugins: pidfile: Fix memory leak in pidfile_callback()

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