Repository: groovy Updated Branches: refs/heads/master 10c6ef9cc -> 50ebdf164
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/52bb559c Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/52bb559c Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/52bb559c Branch: refs/heads/master Commit: 52bb559c4700b62a79d51ee33b4a25bd7ed00d83 Parents: 10c6ef9 Author: liningrui <[email protected]> Authored: Fri Mar 2 11:44:23 2018 +0800 Committer: sunlan <[email protected]> Committed: Mon Mar 5 18:18:31 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/52bb559c/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) {
