Flush pending output before entering or exiting alternate screen rather
authornicm <nicm@openbsd.org>
Wed, 27 Jan 2021 10:42:52 +0000 (10:42 +0000)
committernicm <nicm@openbsd.org>
Wed, 27 Jan 2021 10:42:52 +0000 (10:42 +0000)
than leaking it, oss-fuzz issue 29959.

usr.bin/tmux/screen-write.c

index 917fbae..d9a5bf8 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.191 2021/01/22 11:28:33 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.192 2021/01/27 10:42:52 nicm Exp $ */
 
 /*
  * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1970,6 +1970,8 @@ screen_write_alternateon(struct screen_write_ctx *ctx, struct grid_cell *gc,
 
        if (wp != NULL && !options_get_number(wp->options, "alternate-screen"))
                return;
+
+       screen_write_collect_flush(ctx, 0, __func__);
        screen_alternate_on(ctx->s, gc, cursor);
 
        screen_write_initctx(ctx, &ttyctx, 1);
@@ -1986,6 +1988,8 @@ screen_write_alternateoff(struct screen_write_ctx *ctx, struct grid_cell *gc,
 
        if (wp != NULL && !options_get_number(wp->options, "alternate-screen"))
                return;
+
+       screen_write_collect_flush(ctx, 0, __func__);
        screen_alternate_off(ctx->s, gc, cursor);
 
        screen_write_initctx(ctx, &ttyctx, 1);