You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/03/05 23:57:10 UTC
groovy git commit: Fix ArrayIndexOutOfBoundsException in
CallSiteWriter.getCreateArraySignature()(closes #669)
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_4_X 2aa0a54ed -> 84eb68b4c
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.
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/84eb68b4
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/84eb68b4
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/84eb68b4
Branch: refs/heads/GROOVY_2_4_X
Commit: 84eb68b4ce2371f02fab11bbef6e83c984f17952
Parents: 2aa0a54
Author: sunlan <su...@apache.org>
Authored: Tue Mar 6 07:57:05 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Tue Mar 6 07:57:05 2018 +0800
----------------------------------------------------------------------
.../org/codehaus/groovy/classgen/asm/CallSiteWriter.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/84eb68b4/src/main/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/CallSiteWriter.java b/src/main/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
index 84c5843..41de754 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
@@ -67,9 +67,14 @@ import static org.objectweb.asm.Opcodes.RETURN;
* use this class in your code
*/
public class CallSiteWriter {
-
- private static String [] sig = new String [255];
+ private static final int SIG_ARRAY_LENGTH = 255;
+ private static String [] sig = new String [SIG_ARRAY_LENGTH];
private static String getCreateArraySignature(int numberOfArguments) {
+ if (numberOfArguments >= SIG_ARRAY_LENGTH) {
+ throw new IllegalArgumentException(String.format(
+ "The max number of arguments is %s, actual got %s",
+ SIG_ARRAY_LENGTH, numberOfArguments));
+ }
if (sig[numberOfArguments] == null) {
StringBuilder sb = new StringBuilder("(");
for (int i = 0; i != numberOfArguments; ++i) {