Browse Source

ZOOKEEPER-2039 Jute compareBytes incorrect comparison index (Ian Dimayuga via fpj)


git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1626008 13f79535-47bb-0310-9956-ffa450edef68
Flavio Paiva Junqueira 11 years ago
parent
commit
375d298996
2 changed files with 12 additions and 10 deletions
  1. 2 0
      CHANGES.txt
  2. 10 10
      src/java/main/org/apache/jute/Utils.java

+ 2 - 0
CHANGES.txt

@@ -13,6 +13,8 @@ IMPROVEMENTS:
   ZOOKEEPER-2030 dynamicConfigFile should have an absolute path, not a relative
   path, to the dynamic configuration file (Alexander Shraer via michim)
 
+  ZOOKEEPER-2039 Jute compareBytes incorrect comparison index (Ian Dimayuga via fpj) 
+
 Release 3.5.0 - 8/4/2014
 
 NEW FEATURES:

+ 10 - 10
src/java/main/org/apache/jute/Utils.java

@@ -268,15 +268,15 @@ public class Utils {
         return stream.toByteArray();
     }
     public static int compareBytes(byte b1[], int off1, int len1, byte b2[], int off2, int len2) {
-    	int i;
-    	for(i=0; i < len1 && i < len2; i++) {
-    		if (b1[off1+i] != b2[off2+i]) {
-    			return b1[off1+i] < b2[off2+1] ? -1 : 1;
-    		}
-    	}
-    	if (len1 != len2) {
-    		return len1 < len2 ? -1 : 1;
-    	}
-    	return 0;
+        int i;
+        for(i=0; i < len1 && i < len2; i++) {
+            if (b1[off1+i] != b2[off2+i]) {
+                return b1[off1+i] < b2[off2+i] ? -1 : 1;
+            }
+        }
+        if (len1 != len2) {
+            return len1 < len2 ? -1 : 1;
+        }
+        return 0;
     }
 }