This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new c2a36e3  Fix resource leak on exception path.
c2a36e3 is described below

commit c2a36e3032231b4937a8efa37c6d6e1c72b8733f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Apr 17 17:23:30 2019 +0100

    Fix resource leak on exception path.
    
    Identified by Coverity scan.
---
 java/org/apache/jasper/compiler/JspUtil.java | 13 +++++++++++--
 webapps/docs/changelog.xml                   |  4 ++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/jasper/compiler/JspUtil.java 
b/java/org/apache/jasper/compiler/JspUtil.java
index 5c09c52..bbe42ab 100644
--- a/java/org/apache/jasper/compiler/JspUtil.java
+++ b/java/org/apache/jasper/compiler/JspUtil.java
@@ -919,8 +919,17 @@ public class JspUtil {
 
         InputStreamReader reader = null;
         InputStream in = getInputStream(fname, jar, ctxt);
-        for (int i = 0; i < skip; i++) {
-            in.read();
+        try {
+            for (int i = 0; i < skip; i++) {
+                in.read();
+            }
+        } catch (IOException ioe) {
+            try {
+                in.close();
+            } catch (IOException e) {
+                // Ignore
+            }
+            throw ioe;
         }
         try {
             reader = new InputStreamReader(in, encoding);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a417b9a..c3ce6cc 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -67,6 +67,10 @@
         Fix a potential resource leak on some exception paths in the
         <code>DataSourceRealm</code>. Identified by Coverity scan. (markt)
       </fix>
+      <fix>
+        Fix a potential resource leak on an exception path when parsing JSP
+        files. Identified by Coverity scan. (markt)
+      </fix>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to