diff options
author | 2017-09-11 06:40:46 +0000 | |
---|---|---|
committer | 2017-09-11 06:40:46 +0000 | |
commit | d5f2217b88c54d1571182897d7801b4f470c203e (patch) | |
tree | 8bcd97a666342aad76a59bef1f83877651f085e2 | |
parent | Avoid using an uninitialised variable. Found by the clang static analyser. (diff) | |
download | wireguard-openbsd-d5f2217b88c54d1571182897d7801b4f470c203e.tar.xz wireguard-openbsd-d5f2217b88c54d1571182897d7801b4f470c203e.zip |
Do not free more lines than are available in the history.
-rw-r--r-- | usr.bin/tmux/grid.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index f98844259e5..cb9953c72e5 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.76 2017/09/10 14:36:12 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.77 2017/09/11 06:40:46 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -292,12 +292,14 @@ grid_collect_history(struct grid *gd) { u_int ny; - if (gd->hsize < gd->hlimit) + if (gd->hsize == 0 || gd->hsize < gd->hlimit) return; ny = gd->hlimit / 10; if (ny < 1) ny = 1; + if (ny > gd->hsize) + ny = gd->hsize; /* * Free the lines from 0 to ny then move the remaining lines over |