mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-27 21:58:45 +03:00
fixed buffer overflow in TypedArray.prototype.lastIndexOf()
This commit is contained in:
parent
9ce544289f
commit
c927eca49a
18
quickjs.c
18
quickjs.c
@ -53619,22 +53619,12 @@ static JSValue js_typed_array_indexOf(JSContext *ctx, JSValueConst this_val,
|
|||||||
if (special == special_lastIndexOf) {
|
if (special == special_lastIndexOf) {
|
||||||
k = len - 1;
|
k = len - 1;
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (JS_ToFloat64(ctx, &d, argv[1]))
|
int64_t k1;
|
||||||
|
if (JS_ToInt64Clamp(ctx, &k1, argv[1], -1, len - 1, len))
|
||||||
goto exception;
|
goto exception;
|
||||||
if (isnan(d)) {
|
k = k1;
|
||||||
k = 0;
|
if (k < 0)
|
||||||
} else {
|
|
||||||
if (d >= 0) {
|
|
||||||
if (d < k) {
|
|
||||||
k = d;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
d += len;
|
|
||||||
if (d < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
k = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stop = -1;
|
stop = -1;
|
||||||
inc = -1;
|
inc = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user