Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -41777,33 +41777,31 @@ static JSValue js_create_iterator_helper(JSContext *ctx, JSValueConst this_val,
double dlimit;
v = JS_ToNumber(ctx, argv[0]);
if (JS_IsException(v))
return JS_EXCEPTION;
goto fail;
// Check for Infinity.
if (JS_ToFloat64(ctx, &dlimit, v)) {
JS_FreeValue(ctx, v);
return JS_EXCEPTION;
goto fail;
}
if (isnan(dlimit)) {
JS_FreeValue(ctx, v);
goto fail;
goto range_error;
}
if (!isfinite(dlimit)) {
JS_FreeValue(ctx, v);
if (dlimit < 0)
goto fail;
goto range_error;
else
count = MAX_SAFE_INTEGER;
} else {
v = JS_ToIntegerFree(ctx, v);
if (JS_IsException(v))
return JS_EXCEPTION;
goto fail;
if (JS_ToInt64Free(ctx, &count, v))
return JS_EXCEPTION;
}
if (count < 0) {
fail:
return JS_ThrowRangeError(ctx, "must be positive");
goto fail;
}
if (count < 0)
goto range_error;
}
break;
case JS_ITERATOR_HELPER_KIND_FILTER:
Expand All @@ -41812,7 +41810,7 @@ static JSValue js_create_iterator_helper(JSContext *ctx, JSValueConst this_val,
{
func = argv[0];
if (check_function(ctx, func))
return JS_EXCEPTION;
goto fail;
}
break;
default:
Expand All @@ -41822,17 +41820,17 @@ static JSValue js_create_iterator_helper(JSContext *ctx, JSValueConst this_val,

method = JS_GetProperty(ctx, this_val, JS_ATOM_next);
if (JS_IsException(method))
return JS_EXCEPTION;
goto fail;
obj = JS_NewObjectClass(ctx, JS_CLASS_ITERATOR_HELPER);
if (JS_IsException(obj)) {
JS_FreeValue(ctx, method);
return JS_EXCEPTION;
goto fail;
}
it = js_malloc(ctx, sizeof(*it));
if (!it) {
JS_FreeValue(ctx, obj);
JS_FreeValue(ctx, method);
return JS_EXCEPTION;
goto fail;
}
it->kind = magic;
it->obj = js_dup(this_val);
Expand All @@ -41844,6 +41842,11 @@ static JSValue js_create_iterator_helper(JSContext *ctx, JSValueConst this_val,
it->done = 0;
JS_SetOpaqueInternal(obj, it);
return obj;
range_error:
JS_ThrowRangeError(ctx, "must be positive");
fail:
JS_IteratorClose(ctx, this_val, true);
return JS_EXCEPTION;
}

static JSValue js_iterator_proto_func(JSContext *ctx, JSValueConst this_val,
Expand All @@ -41856,8 +41859,10 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValueConst this_val,

if (check_iterator(ctx, this_val) < 0)
return JS_EXCEPTION;
func = JS_UNDEFINED;
method = JS_UNDEFINED;
if (check_function(ctx, argv[0]))
return JS_EXCEPTION;
goto fail;
func = js_dup(argv[0]);
method = JS_GetProperty(ctx, this_val, JS_ATOM_next);
if (JS_IsException(method))
Expand Down Expand Up @@ -42006,9 +42011,11 @@ static JSValue js_iterator_proto_reduce(JSContext *ctx, JSValueConst this_val,

if (check_iterator(ctx, this_val) < 0)
return JS_EXCEPTION;
if (check_function(ctx, argv[0]))
return JS_EXCEPTION;
acc = JS_UNDEFINED;
func = JS_UNDEFINED;
method = JS_UNDEFINED;
if (check_function(ctx, argv[0]))
goto exception;
func = js_dup(argv[0]);
method = JS_GetProperty(ctx, this_val, JS_ATOM_next);
if (JS_IsException(method))
Expand Down
20 changes: 0 additions & 20 deletions test262_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,6 @@ test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: Test262Er
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: strict mode: Test262Error: Expected SameValue(«"undefined"», «"function"») to be true
test262/test/built-ins/Iterator/prototype/constructor/weird-setter.js:23: TypeError: cannot read property 'call' of undefined
test262/test/built-ins/Iterator/prototype/constructor/weird-setter.js:23: strict mode: TypeError: cannot read property 'call' of undefined
test262/test/built-ins/Iterator/prototype/drop/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/drop/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/every/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/every/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/filter/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/filter/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/find/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/find/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/flatMap/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/flatMap/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/forEach/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/forEach/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/map/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/map/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/reduce/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/reduce/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/some/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/some/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/take/argument-validation-failure-closes-underlying.js:18: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Iterator/prototype/take/argument-validation-failure-closes-underlying.js:18: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
test262/test/built-ins/Object/defineProperties/typedarray-backed-by-resizable-buffer.js:20: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
test262/test/built-ins/Object/defineProperties/typedarray-backed-by-resizable-buffer.js:20: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
test262/test/built-ins/Object/defineProperty/coerced-P-grow.js:45: TypeError: out-of-bound index in typed array
Expand Down