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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 6c96fe8124 Fix equals on a null MB
6c96fe8124 is described below

commit 6c96fe812446787fe9632457edf2e0f12d4face2
Author: remm <[email protected]>
AuthorDate: Wed May 20 12:51:42 2026 +0200

    Fix equals on a null MB
    
    Handle special arithmetic case of Long.MIN_VALUE.
---
 java/org/apache/tomcat/util/buf/MessageBytes.java | 9 ++++++---
 webapps/docs/changelog.xml                        | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/MessageBytes.java 
b/java/org/apache/tomcat/util/buf/MessageBytes.java
index 6566fac7c8..393e8e9123 100644
--- a/java/org/apache/tomcat/util/buf/MessageBytes.java
+++ b/java/org/apache/tomcat/util/buf/MessageBytes.java
@@ -481,8 +481,7 @@ public final class MessageBytes implements Cloneable, 
Serializable {
         if (mb.type == T_BYTES && type == T_CHARS) {
             return mb.byteC.equals(charC);
         }
-        // can't happen
-        return true;
+        return (mb.type == T_NULL && type == T_NULL);
     }
 
 
@@ -642,7 +641,11 @@ public final class MessageBytes implements Cloneable, 
Serializable {
             buf[end++] = (byte) '0';
         }
         if (l < 0) {
-            current = -l;
+            if (l == Long.MIN_VALUE) {
+                current = Long.MAX_VALUE;
+            } else {
+                current = -l;
+            }
             buf[end++] = (byte) '-';
         }
         while (current > 0) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 7173afb548..047ae177af 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -163,6 +163,9 @@
         Properly use <code>pollerThreadPriority</code> for the NIO poller
         thread. (remm)
       </fix>
+      <fix>
+        Fix <code>MessageByte.equals</code> if called on a null MB. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to