Skip to content

Commit 0d05dfc

Browse files
Peter Markiakosthekiss
authored andcommitted
Remove bad assertion in ecma_builtin_json_str_helper (#2521)
Fixes #2494 JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
1 parent 08e4a95 commit 0d05dfc

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-json.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -923,13 +923,16 @@ static ecma_value_t ecma_builtin_json_str_helper (const ecma_value_t arg1, /**<
923923
empty_str_p,
924924
arg1,
925925
false);
926-
JERRY_ASSERT (ecma_is_value_true (put_comp_val));
927-
ecma_free_value (put_comp_val);
928-
ECMA_TRY_CATCH (str_val,
929-
ecma_builtin_json_str (empty_str_p, obj_wrapper_p, &context),
930-
ret_value);
931-
ret_value = ecma_copy_value (str_val);
932-
ECMA_FINALIZE (str_val);
926+
927+
if (ecma_is_value_true (put_comp_val))
928+
{
929+
ret_value = ecma_builtin_json_str (empty_str_p, obj_wrapper_p, &context);
930+
}
931+
else
932+
{
933+
ret_value = ECMA_VALUE_UNDEFINED;
934+
}
935+
933936
ecma_free_value (put_comp_val);
934937
ecma_deref_ecma_string (empty_str_p);
935938
ecma_deref_object (obj_wrapper_p);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
Object.defineProperty(Object.prototype, "", {});
16+
assert(JSON.stringify() === undefined)

0 commit comments

Comments
 (0)