8331940: ClassFile API ArrayIndexOutOfBoundsException with certain class files

Reviewed-by: liach, psandoz
This commit is contained in:
Adam Sotona 2024-05-15 16:14:15 +00:00
parent 61aff6db15
commit 42ccb74399
2 changed files with 20 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -237,6 +237,10 @@ public final class CodeImpl
int pEnd = p + (nLn * 4);
for (; p < pEnd; p += 4) {
int startPc = classReader.readU2(p);
if (startPc > codeLength) {
throw new IllegalArgumentException(String.format(
"Line number start_pc out of range; start_pc=%d, codeLength=%d", startPc, codeLength));
}
int lineNumber = classReader.readU2(p + 2);
lineNumbers[startPc] = lineNumber;
}