From 144c3ba874d8ba2404bd2d2cc76b3a262f477e07 Mon Sep 17 00:00:00 2001 From: Roland Takacs Date: Thu, 30 Jul 2015 10:55:38 +0200 Subject: [PATCH] Fix assertion 'mem_pools == NULL' in the Date constructor. JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com --- .../builtin-objects/ecma-builtin-date.cpp | 4 ++++ tests/jerry/date-construct.js | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp index a90cfad9d9..fe471c1353 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp @@ -172,6 +172,10 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t { ret_value = ecma_make_normal_completion_value (ecma_make_number_value (prim_value_p)); } + else + { + ecma_dealloc_number (prim_value_p); + } return ret_value; } /* ecma_date_construct_helper */ diff --git a/tests/jerry/date-construct.js b/tests/jerry/date-construct.js index c5d485f92e..4834ee450f 100644 --- a/tests/jerry/date-construct.js +++ b/tests/jerry/date-construct.js @@ -63,3 +63,22 @@ assert (d.valueOf() == 8.64e+15); d = new Date(8.64e+15 + 1); assert (isNaN(d.valueOf())); + +var Obj = function (val) +{ + this.value = val; + this.valueOf = function () { throw new ReferenceError ("valueOf-" + this.value); }; + this.toString = function () { throw new ReferenceError ("toString-"+ this.value); }; +}; + +try +{ + d = new Date (new Obj (1), new Obj (2)); + // Should not be reached. + assert (false); +} +catch (e) +{ + assert (e instanceof ReferenceError); + assert (e.message === "valueOf-1"); +}