Skip to content

Commit 9cc7ccf

Browse files
committed
fix style and bug
1 parent 241aecc commit 9cc7ccf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include "classfile/symbolTable.hpp"
2828
#include "classfile/systemDictionary.hpp"
2929
#include "classfile/vmClasses.hpp"
30-
#include "code/scopeDesc.hpp"
3130
#include "code/nmethod.hpp"
31+
#include "code/scopeDesc.hpp"
3232
#include "compiler/compileBroker.hpp"
3333
#include "compiler/compilerEvent.hpp"
3434
#include "compiler/compilerOracle.hpp"
@@ -2254,6 +2254,16 @@ static jobject read_field_value(Handle obj, long displacement, jchar type_char,
22542254
if (!aligned) {
22552255
JVMCI_THROW_MSG_NULL(IllegalArgumentException, "read is unaligned");
22562256
}
2257+
if (obj->is_array()) {
2258+
// Disallow reading after the last element of an array
2259+
size_t array_length = arrayOop(obj())->length();
2260+
int lh = obj->klass()->layout_helper();
2261+
size_t size_in_bytes = array_length << Klass::layout_helper_log2_element_size(lh);
2262+
size_in_bytes += Klass::layout_helper_header_size(lh);
2263+
if ((size_t) displacement + basic_type_elemsize > size_in_bytes) {
2264+
JVMCI_THROW_MSG_NULL(IllegalArgumentException, "reading after last array element");
2265+
}
2266+
}
22572267
if (basic_type == T_OBJECT) {
22582268
if (obj->is_objArray()) {
22592269
if (displacement < arrayOopDesc::base_offset_in_bytes(T_OBJECT)) {

0 commit comments

Comments
 (0)