From e61f41a0bc9301df25a8971cc5167a923f02f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Borb=C3=A9ly?= Date: Mon, 3 Aug 2015 15:17:33 +0200 Subject: [PATCH] Fix of memory leak in Function.prototype.bind function. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related issue: #511 JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com --- jerry-core/ecma/base/ecma-helpers.cpp | 5 +++++ tests/jerry/function-prototype-bind.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/jerry-core/ecma/base/ecma-helpers.cpp b/jerry-core/ecma/base/ecma-helpers.cpp index f6fa11a49..d1c55f9e0 100644 --- a/jerry-core/ecma/base/ecma-helpers.cpp +++ b/jerry-core/ecma/base/ecma-helpers.cpp @@ -801,8 +801,13 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */ case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31: /* an integer (bit-mask) */ case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63: /* an integer (bit-mask) */ case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_TARGET_FUNCTION: + { + break; + } + case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_BOUND_THIS: { + ecma_free_value (property_value, false); break; } diff --git a/tests/jerry/function-prototype-bind.js b/tests/jerry/function-prototype-bind.js index 60f5d1e98..7e619ab5c 100644 --- a/tests/jerry/function-prototype-bind.js +++ b/tests/jerry/function-prototype-bind.js @@ -115,6 +115,9 @@ assert (foo == 3); assert (foo instanceof Number); assert (foo.prototype === undefined); +var func = Number.prototype.toString.bind('foo'); +assert (func instanceof Function); + try { var this_obj = this.constructor; var bound = this_obj.bind(null, "foo");