commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1410058 - /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java
Date Thu, 15 Nov 2012 22:18:21 GMT
Author: henrib
Date: Thu Nov 15 22:18:20 2012
New Revision: 1410058

URL: http://svn.apache.org/viewvc?rev=1410058&view=rev
Log:
Added a check to avoid an array out of bounds when a method exists with multiple signatures
including a vararg and a no-arg

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java?rev=1410058&r1=1410057&r2=1410058&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java
(original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/internal/introspection/MethodKey.java
Thu Nov 15 22:18:20 2012
@@ -629,7 +629,7 @@ public final class MethodKey {
             // there's just one more methodArg than class arg
             // and the last methodArg is an array, then treat it as a vararg
             if (methodArgs.length == classes.length
-                    || methodArgs.length == classes.length + 1 && methodArgs[methodArgs.length
- 1].isArray()) {
+                || ((methodArgs.length == classes.length + 1) && methodArgs[methodArgs.length
- 1].isArray())) {
                 // this will properly match when the last methodArg
                 // is an array/varargs and the last class is the type of array
                 // (e.g. String when the method is expecting String...)
@@ -647,7 +647,7 @@ public final class MethodKey {
                 return true;
             }
             // more arguments given than the method accepts; check for varargs
-            if (methodArgs.length > 0) {
+            if (methodArgs.length > 0 && classes.length > 0) {
                 // check that the last methodArg is an array
                 Class<?> lastarg = methodArgs[methodArgs.length - 1];
                 if (!lastarg.isArray()) {



Mime
View raw message