summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2018-11-19 13:35:40 +0000
committernicm <nicm@openbsd.org>2018-11-19 13:35:40 +0000
commitb32e1d34e10a0da806823f57f02a4ae6e93d756e (patch)
tree60ce146238243ec139a9af28986d7606c4a4871d /usr.bin/tmux/tty.c
parentUtilize sigio with sockets. (diff)
downloadwireguard-openbsd-b32e1d34e10a0da806823f57f02a4ae6e93d756e.tar.xz
wireguard-openbsd-b32e1d34e10a0da806823f57f02a4ae6e93d756e.zip
evbuffer_new and bufferevent_new can both fail (when malloc fails) and
return NULL. GitHub issue 1547.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index e5298c6f368..24761b71471 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.310 2018/10/25 15:13:38 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.311 2018/11/19 13:35:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);