# HG changeset patch # User kvn # Date 1350569191 25200 # Node ID e81a8af10cd954bcae5a3ddba70b642c853ce06c # Parent cfe522e6461cbb99c6a7b140427bd7349cd05086 8001071: Add simple range check into VM implemenation of Unsafe access methods Summary: Add simple check in debug version of VM. Reviewed-by: twisti, johnc diff -r cfe522e6461c -r e81a8af10cd9 src/share/vm/prims/unsafe.cpp --- a/src/share/vm/prims/unsafe.cpp Wed Oct 17 12:09:32 2012 -0700 +++ b/src/share/vm/prims/unsafe.cpp Thu Oct 18 07:06:31 2012 -0700 @@ -124,6 +124,8 @@ assert((void*)p->obj_field_addr((jint)byte_offset) == ptr_plus_disp, "raw [ptr+disp] must be consistent with oop::field_base"); } + jlong p_size = HeapWordSize * (jlong)(p->size()); + assert(byte_offset < p_size, err_msg("Unsafe access: offset " INT64_FORMAT " > object's size " INT64_FORMAT, byte_offset, p_size)); } #endif if (sizeof(char*) == sizeof(jint)) // (this constant folds!)