changeset 24118:3ce198ad35a6

check displacement >= 0 (JDK-8177673)
author Doug Simon <doug.simon@oracle.com>
date Mon, 03 Apr 2017 14:47:25 +0200
parents 6508ce8d068f
children c7f35230907d
files jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java	Sun Apr 02 00:38:39 2017 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java	Mon Apr 03 14:47:25 2017 +0200
@@ -96,7 +96,7 @@
             int length = Array.getLength(object);
             long arrayEnd = headerSize + (sizeOfElement * length);
             boolean aligned = ((displacement - headerSize) % sizeOfElement) == 0;
-            if (displacement > (arrayEnd - sizeOfElement) || (kind == JavaKind.Object && !aligned)) {
+            if (displacement < 0 || displacement > (arrayEnd - sizeOfElement) || (kind == JavaKind.Object && !aligned)) {
                 int index = (int) ((displacement - headerSize) / sizeOfElement);
                 throw new AssertionError("Unsafe array access: reading element of kind " + kind +
                                 " at offset " + displacement + " (index ~ " + index + ") in " +