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

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


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

commit c6ccda76dfe9ff04261216bce798beb1f7734efd
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 9416f05..f9ee150 100644
--- a/java/org/apache/jasper/compiler/JspUtil.java
+++ b/java/org/apache/jasper/compiler/JspUtil.java
@@ -946,8 +946,17 @@ public class JspUtil {
 
         InputStreamReader reader = null;
         InputStream in = getInputStream(fname, jarFile, ctxt, err);
-        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 accad91..1f96dbe 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -77,6 +77,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