Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 09d41546e -> 296bf35ef


Fix ArrayIndexOutOfBoundsException in 
CallSiteWriter.getCreateArraySignature()(closes #669)

It would throw ArrayIndexOutOfBoundsException if the numberOfArguments exceed 
255,
but there is no check for array index and it's hard to get the root cause to 
users.

We should throw a more readable exception here.

(cherry picked from commit 52bb559)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5966aad1
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5966aad1
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5966aad1

Branch: refs/heads/GROOVY_2_6_X
Commit: 5966aad1ee17315a8ce22b4a843572622fef241f
Parents: 09d4154
Author: liningrui <[email protected]>
Authored: Fri Mar 2 11:44:23 2018 +0800
Committer: sunlan <[email protected]>
Committed: Tue Mar 6 07:51:07 2018 +0800

----------------------------------------------------------------------
 .../java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java   | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5966aad1/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java 
b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
index 3e3f0e1..334eebd 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
@@ -70,6 +70,11 @@ public class CallSiteWriter {
     
     private static String [] sig = new String [255];
     private static String getCreateArraySignature(int numberOfArguments) {
+        if (numberOfArguments >= 255) {
+            throw new IllegalArgumentException(String.format(
+                      "The max number of arguments is 255, actual got %s",
+                      numberOfArguments);
+        }
         if (sig[numberOfArguments] == null) {
             StringBuilder sb = new StringBuilder("(");
             for (int i = 0; i != numberOfArguments; ++i) {

Reply via email to