Skip to content

Commit a3cd2d7

Browse files
rerobikadbatyai
authored andcommitted
This argument must be pseudo-array in {Map/Set}Iterator.prototype.next routine (#2960)
This patch fixes #2950. Co-authored-by: Gabor Loki loki@inf.u-szeged.hu JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent 06000b5 commit a3cd2d7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

jerry-core/ecma/operations/ecma-container-object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
698698
ecma_object_t *obj_p = ecma_get_object_from_value (this_val);
699699
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
700700

701-
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY
702-
&& ext_obj_p->u.pseudo_array.type != iterator_type)
701+
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
702+
|| ext_obj_p->u.pseudo_array.type != iterator_type)
703703
{
704704
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator."));
705705
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var str = new Map();
16+
var iterator = str[ Symbol.iterator ]();
17+
18+
try {
19+
iterator.next.call({ })
20+
assert(false);
21+
} catch (e) {
22+
assert(e instanceof TypeError);
23+
}

0 commit comments

Comments
 (0)