#29 avoid potential NPE
[nikiroo-utils.git] / src / jexer / backend / ECMA48Terminal.java
index 7edb64b20e87b519fa939ababfc781a7c6cb54e2..84f6528c5a348832642bc21315dea8b1ddbb5bbc 100644 (file)
@@ -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();