Skip to content

Commit d420be3

Browse files
committed
Fix 'Segmentation fault in re_get_value'
Related issue: #782 JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent 433f070 commit d420be3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

jerry-core/ecma/operations/ecma-regexp-object.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,11 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
12561256
re_compiled_code_t *bc_p = ECMA_GET_POINTER (re_compiled_code_t,
12571257
bytecode_prop_p->u.internal_property.value);
12581258

1259+
if (bc_p == NULL)
1260+
{
1261+
return ecma_raise_type_error ("Incompatible type");
1262+
}
1263+
12591264
ecma_string_t *input_string_p = ecma_get_string_from_value (input_string);
12601265
lit_utf8_size_t input_string_size = ecma_string_get_size (input_string_p);
12611266

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2016 Samsung Electronics Co., Ltd.
2+
// Copyright 2016 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
try
17+
{
18+
String.prototype.search(RegExp.prototype);
19+
assert (false);
20+
}
21+
catch (e)
22+
{
23+
assert (e instanceof TypeError);
24+
}

0 commit comments

Comments
 (0)