This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new c63ba52b5c Avoid possible NPEs
c63ba52b5c is described below
commit c63ba52b5cf734fe66bd2a08f0131a8e8a968d1e
Author: remm <[email protected]>
AuthorDate: Wed Jan 17 12:49:02 2024 +0100
Avoid possible NPEs
Found by coverity.
---
java/org/apache/jasper/servlet/JspCServletContext.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/jasper/servlet/JspCServletContext.java
b/java/org/apache/jasper/servlet/JspCServletContext.java
index cfca211075..074357e4c4 100644
--- a/java/org/apache/jasper/servlet/JspCServletContext.java
+++ b/java/org/apache/jasper/servlet/JspCServletContext.java
@@ -348,7 +348,11 @@ public class JspCServletContext implements ServletContext {
return null;
}
try {
- File f = new File(getResource(path).toURI());
+ URL url = getResource(path);
+ if (url == null) {
+ return null;
+ }
+ File f = new File(url.toURI());
return f.getAbsolutePath();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
@@ -425,7 +429,11 @@ public class JspCServletContext implements ServletContext {
@Override
public InputStream getResourceAsStream(String path) {
try {
- return getResource(path).openStream();
+ URL url = getResource(path);
+ if (url == null) {
+ return null;
+ }
+ return url.openStream();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
return null;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]