8168146: Infinite recursion in Uint8ClampedArray.set
Reviewed-by: sundar
This commit is contained in:
parent
8c0688d486
commit
6c3ae31f78
@ -82,7 +82,6 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
|
||||
private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
|
||||
private static final MethodHandle RINT_D = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", double.class, double.class).methodHandle();
|
||||
private static final MethodHandle RINT_O = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", Object.class, Object.class).methodHandle();
|
||||
private static final MethodHandle CLAMP_LONG = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "clampLong", long.class, long.class).methodHandle();
|
||||
|
||||
private Uint8ClampedArrayData(final ByteBuffer nb, final int start, final int end) {
|
||||
super((nb.position(start).limit(end)).slice(), end - start);
|
||||
@ -124,8 +123,6 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
|
||||
return MH.filterArguments(setter, 2, RINT_O);
|
||||
} else if (elementType == double.class) {
|
||||
return MH.filterArguments(setter, 2, RINT_D);
|
||||
} else if (elementType == long.class) {
|
||||
return MH.filterArguments(setter, 2, CLAMP_LONG);
|
||||
}
|
||||
}
|
||||
return setter;
|
||||
@ -195,7 +192,7 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
|
||||
|
||||
@Override
|
||||
public ArrayData set(final int index, final double value, final boolean strict) {
|
||||
return set(index, rint(value), strict);
|
||||
return set(index, (int) rint(value), strict);
|
||||
}
|
||||
|
||||
private static double rint(final double rint) {
|
||||
@ -207,15 +204,6 @@ public final class NativeUint8ClampedArray extends ArrayBufferView {
|
||||
return rint(JSType.toNumber(rint));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static long clampLong(final long l) {
|
||||
if(l < 0L) {
|
||||
return 0L;
|
||||
} else if(l > 0xffL) {
|
||||
return 0xffL;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
37
nashorn/test/script/basic/JDK-8168146.js
Normal file
37
nashorn/test/script/basic/JDK-8168146.js
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8168146: Infinite recursion in Uint8ClampedArray.set
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
*/
|
||||
|
||||
|
||||
var a = new Uint8ClampedArray(10);
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
a[i] = i;
|
||||
Assert.assertTrue(a[i] === i);
|
||||
}
|
Loading…
Reference in New Issue
Block a user