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

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


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

commit c9d1318655b849958d30bf8fff50f9d071714611
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 d7d5b9dd0e..377fed979f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -159,6 +159,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