From f10a48df96c86db45c4ec93341a29e5c739d71af Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Thu, 6 Aug 2015 14:22:09 +0200 Subject: [PATCH] Fix assertion 'mem_pools == NULL' failed in Function.constructor JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com --- .../ecma/builtin-objects/ecma-builtin-function.cpp | 4 ++++ tests/jerry/function-construct.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp index 8a8df5005..fdc093de5 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp @@ -131,6 +131,10 @@ ecma_builtin_function_helper_get_arguments (const ecma_value_t *arguments_list_p { ret_value = ecma_make_normal_completion_value (ecma_make_string_value (arguments_str_p)); } + else + { + ecma_deref_ecma_string (arguments_str_p); + } return ret_value; } /* ecma_builtin_function_helper_get_arguments */ diff --git a/tests/jerry/function-construct.js b/tests/jerry/function-construct.js index fed3df1b9..66a1e7da9 100644 --- a/tests/jerry/function-construct.js +++ b/tests/jerry/function-construct.js @@ -98,6 +98,20 @@ catch (e) assert (e instanceof TypeError); } +var p = { toString : function() { throw 1; } }; +var body = { toString : function() { throw "body"; } }; + +try +{ + new Function (p, body); + // Should not be reached. + assert (false); +} +catch (e) +{ + assert (e === 1); +} + // Check SyntaxError handling try {