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 39116f891d Fix unlikely NPE
39116f891d is described below

commit 39116f891de8589d31888eaab4233526967ccd64
Author: remm <r...@apache.org>
AuthorDate: Mon Sep 18 12:53:38 2023 +0200

    Fix unlikely NPE
    
    Found by coverity.
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 17be76bae3..bd34a961b8 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1452,8 +1452,12 @@ public class NioEndpoint extends 
AbstractNetworkChannelEndpoint<NioChannel,Socke
         public SendfileState processSendfile(SendfileDataBase sendfileData) {
             setSendfileData((SendfileData) sendfileData);
             SelectionKey key = 
getSocket().getIOChannel().keyFor(getPoller().getSelector());
-            // Might as well do the first write on this thread
-            return getPoller().processSendfile(key, this, true);
+            if (key == null) {
+                return SendfileState.ERROR;
+            } else {
+                // Might as well do the first write on this thread
+                return getPoller().processSendfile(key, this, true);
+            }
         }
 
 


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

Reply via email to