Avoid possible exceptions with isTty

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1736053 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
index bae9d3b..adb78cd 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
@@ -203,7 +203,10 @@
 
     public boolean isTty(int fd) {
         // TODO: this assumes that the session is always created with input/output tty streams
-        return !toclose[fd];
+        if (fd < 0 || fd > streams.length) {
+            return false;
+        }
+        return streams[fd] != null && !toclose[fd];
     }
 
     public void error(int error) {