aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authornicm <nicm>2018-11-19 13:35:40 +0000
committernicm <nicm>2018-11-19 13:35:40 +0000
commit749f67b7d801eed03345fef9c04206fbd079c3cb (patch)
treec3f0924151a023f0f0fc52e8174577a10be94d64 /tty.c
parentf103927a5232e0d3e8e7ad0e13aa53b4dfa2c87b (diff)
downloadrtmux-749f67b7d801eed03345fef9c04206fbd079c3cb.tar.gz
rtmux-749f67b7d801eed03345fef9c04206fbd079c3cb.tar.bz2
rtmux-749f67b7d801eed03345fef9c04206fbd079c3cb.zip
evbuffer_new and bufferevent_new can both fail (when malloc fails) and
return NULL. GitHub issue 1547.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tty.c b/tty.c
index 6b63aa3b..df47c972 100644
--- a/tty.c
+++ b/tty.c
@@ -258,9 +258,13 @@ tty_open(struct tty *tty, char **cause)
event_set(&tty->event_in, tty->fd, EV_PERSIST|EV_READ,
tty_read_callback, tty);
tty->in = evbuffer_new();
+ if (tty->in == NULL)
+ fatal("out of memory");
event_set(&tty->event_out, tty->fd, EV_WRITE, tty_write_callback, tty);
tty->out = evbuffer_new();
+ if (tty->out == NULL)
+ fatal("out of memory");
evtimer_set(&tty->timer, tty_timer_callback, tty);