groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [1/2] groovy git commit: Fix ArrayIndexOutOfBoundsException in CallSiteWriter.getCreateArraySignature()(closes #669)
Date Mon, 05 Mar 2018 23:52:17 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 0286e2a23 -> f4cb73958


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/dd745e9b
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/dd745e9b
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/dd745e9b

Branch: refs/heads/GROOVY_2_5_X
Commit: dd745e9bdfd32bddf1c45befa6b94eddb74f78d6
Parents: 0286e2a
Author: liningrui <liningrui@baidu.com>
Authored: Fri Mar 2 11:44:23 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Mar 6 07:52:03 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/dd745e9b/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 36f1dda..29f3233 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) {


Mime
View raw message