Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42722
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 10 Jul 2008 21:11:16 +0000 (21:11 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 10 Jul 2008 21:11:16 +0000 (21:11 +0000)
Possible NPE in CGIServlet.java
Patch provided by Nils Hammar

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@675751 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/servlets/CGIServlet.java

index a69cf4e..1de39ac 100644 (file)
@@ -1728,8 +1728,10 @@ public final class CGIServlet extends HttpServlet {
                     }
                 } //replacement for Process.waitFor()
     
-                // Close the output stream used
-                cgiOutput.close();
+                // Close the output stream if used
+                if (cgiOutput != null) {
+                    cgiOutput.close();
+                }
             }
             catch (IOException e){
                 log ("Caught exception " + e);