Check return value from uev_io_init() at runtime

Possible resource leak due to unchecked return value from uev_io_init()
found by Coverity Scan.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-06-04 21:03:36 +02:00
parent e53acd1cdd
commit 662f364d09
3 changed files with 11 additions and 3 deletions
+2 -1
View File
@@ -364,7 +364,8 @@ int api_init(uev_ctx_t *ctx)
if (-1 == listen(sd, 10))
goto error;
return uev_io_init(ctx, &api_watcher, cb, NULL, sd, UEV_READ);
if (!uev_io_init(ctx, &api_watcher, cb, NULL, sd, UEV_READ))
return 0;
error:
_pe("Failed intializing API socket");
+7 -1
View File
@@ -239,7 +239,13 @@ static int spawn_socket(inetd_t *inetd)
}
}
uev_io_init(ctx, &inetd->watcher, socket_cb, inetd->svc, sd, UEV_READ);
if (uev_io_init(ctx, &inetd->watcher, socket_cb, inetd->svc, sd, UEV_READ)) {
FLOG_PERROR("Failed setting up inetd watcher for %s", inetd->name);
close(sd);
return -errno;
}
return 0;
}
+2 -1
View File
@@ -211,7 +211,8 @@ static void init_plugins(uev_ctx_t *ctx)
PLUGIN_ITERATOR(p, tmp) {
if (is_io_plugin(p)) {
_d("Initializing plugin %s for I/O", basename(p->name));
uev_io_init(ctx, &p->watcher, generic_io_cb, p, p->io.fd, p->io.flags);
if (uev_io_init(ctx, &p->watcher, generic_io_cb, p, p->io.fd, p->io.flags))
_e("Failed setting up I/O plugin %s", basename(p->name));
}
}
}