From 0525b2ed026e0d510fdf23f6d8f4cb4562a17e0b Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Sat, 7 Apr 2018 13:49:32 -0400 Subject: [PATCH] #29 avoid potential NPE --- src/jexer/backend/ECMA48Terminal.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jexer/backend/ECMA48Terminal.java b/src/jexer/backend/ECMA48Terminal.java index 7edb64b..84f6528 100644 --- a/src/jexer/backend/ECMA48Terminal.java +++ b/src/jexer/backend/ECMA48Terminal.java @@ -507,9 +507,12 @@ public class ECMA48Terminal extends LogicalScreen e.printStackTrace(); } - // Disable mouse reporting and show cursor - output.printf("%s%s%s", mouse(false), cursor(true), normal()); - output.flush(); + // Disable mouse reporting and show cursor. Defensive null check + // here in case closeTerminal() is called twice. + if (output != null) { + output.printf("%s%s%s", mouse(false), cursor(true), normal()); + output.flush(); + } if (setRawMode) { sttyCooked(); -- 2.27.0