summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-01-01 08:04:21 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-01-01 08:04:21 +0000
commit7f459c87bccc1ab50e713fc259481e5c7acde7e1 (patch)
tree131dd9add67648b5c7ebaef5f08cb06a64d8e5a1 /usr.bin
parenta4a7c9384e0f72db4cc1bf646904ccaad0e0bfed (diff)
Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/status.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 6f1d897dead..7aa78c83505 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.146 2015/12/11 16:37:21 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.147 2016/01/01 08:04:20 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -547,7 +547,7 @@ status_message_set(struct client *c, const char *fmt, ...)
struct message_entry *msg, *msg1;
va_list ap;
int delay;
- u_int first, limit;
+ u_int limit;
limit = options_get_number(global_options, "message-limit");
@@ -564,10 +564,9 @@ status_message_set(struct client *c, const char *fmt, ...)
msg->msg = xstrdup(c->message_string);
TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
- first = c->message_next - limit;
TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
- if (msg->msg_num >= first)
- continue;
+ if (msg->msg_num + limit >= c->message_next)
+ break;
free(msg->msg);
TAILQ_REMOVE(&c->message_log, msg, entry);
free(msg);