aboutsummaryrefslogtreecommitdiff
path: root/fdm.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-09 08:54:39 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-08-09 08:54:39 +0000
commit828a57c2011eb797a9a257d124d48c641b3cac89 (patch)
treecb2539f90c8a1be1ae330c807997dfc2a98e9481 /fdm.c
parentchangelog: add birger to 'contributers' for the upcoming release (diff)
parentHandle allocation failures explicitly in *_init() functions (diff)
Merge branch 'xmalloc-conversion' into master
Diffstat (limited to 'fdm.c')
-rw-r--r--fdm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fdm.c b/fdm.c
index e6f955cc..93ac86ff 100644
--- a/fdm.c
+++ b/fdm.c
@@ -50,6 +50,11 @@ fdm_init(void)
}
struct fdm *fdm = malloc(sizeof(*fdm));
+ if (unlikely(fdm == NULL)) {
+ LOG_ERRNO("malloc() failed");
+ return NULL;
+ }
+
*fdm = (struct fdm){
.epoll_fd = epoll_fd,
.is_polling = false,
@@ -114,6 +119,11 @@ fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
#endif
struct handler *fd_data = malloc(sizeof(*fd_data));
+ if (unlikely(fd_data == NULL)) {
+ LOG_ERRNO("malloc() failed");
+ return false;
+ }
+
*fd_data = (struct handler) {
.fd = fd,
.events = events,