mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Don't rely on a calculation wrapping when applying message-limit, and
break out of the loop early. From Nicolas Viennot.
This commit is contained in:
parent
7e67db79dc
commit
311be04d61
7
status.c
7
status.c
@ -547,7 +547,7 @@ status_message_set(struct client *c, const char *fmt, ...)
|
|||||||
struct message_entry *msg, *msg1;
|
struct message_entry *msg, *msg1;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int delay;
|
int delay;
|
||||||
u_int first, limit;
|
u_int limit;
|
||||||
|
|
||||||
limit = options_get_number(global_options, "message-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);
|
msg->msg = xstrdup(c->message_string);
|
||||||
TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
|
TAILQ_INSERT_TAIL(&c->message_log, msg, entry);
|
||||||
|
|
||||||
first = c->message_next - limit;
|
|
||||||
TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
|
TAILQ_FOREACH_SAFE(msg, &c->message_log, entry, msg1) {
|
||||||
if (msg->msg_num >= first)
|
if (msg->msg_num + limit >= c->message_next)
|
||||||
continue;
|
break;
|
||||||
free(msg->msg);
|
free(msg->msg);
|
||||||
TAILQ_REMOVE(&c->message_log, msg, entry);
|
TAILQ_REMOVE(&c->message_log, msg, entry);
|
||||||
free(msg);
|
free(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user