aboutsummaryrefslogtreecommitdiff
path: root/reaper.c
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2020-08-09 07:55:20 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2020-08-09 07:55:20 +0000
commit4e6100494c4fdea43cb95df1abb68958a89d7935 (patch)
treecb2539f90c8a1be1ae330c807997dfc2a98e9481 /reaper.c
parentConvert most dynamic allocations to use functions from xmalloc.h (diff)
Handle allocation failures explicitly in *_init() functions
Diffstat (limited to 'reaper.c')
-rw-r--r--reaper.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/reaper.c b/reaper.c
index e74dd6cd..adc89e3c 100644
--- a/reaper.c
+++ b/reaper.c
@@ -10,7 +10,6 @@
#define LOG_ENABLE_DBG 0
#include "log.h"
#include "tllist.h"
-#include "xmalloc.h"
struct reaper {
struct fdm *fdm;
@@ -40,7 +39,14 @@ reaper_init(struct fdm *fdm)
return NULL;
}
- struct reaper *reaper = xmalloc(sizeof(*reaper));
+ struct reaper *reaper = malloc(sizeof(*reaper));
+ if (unlikely(reaper == NULL)) {
+ LOG_ERRNO("malloc() failed");
+ close(fd);
+ sigprocmask(SIG_UNBLOCK, &mask, NULL);
+ return NULL;
+ }
+
*reaper = (struct reaper){
.fdm = fdm,
.fd = fd,