Skip to content

Commit 08bcae5

Browse files
author
Roland Takacs
committed
Fix assertion 'mem_pools == NULL' in the Date constructor.
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs [email protected]
1 parent 39cf5aa commit 08bcae5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-date.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
172172
{
173173
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (prim_value_p));
174174
}
175+
else
176+
{
177+
ecma_dealloc_number (prim_value_p);
178+
}
175179

176180
return ret_value;
177181
} /* ecma_date_construct_helper */

tests/jerry/date-construct.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,22 @@ assert (d.valueOf() == 8.64e+15);
6363

6464
d = new Date(8.64e+15 + 1);
6565
assert (isNaN(d.valueOf()));
66+
67+
var Obj = function (val)
68+
{
69+
this.value = val;
70+
this.valueOf = function () { throw new ReferenceError ("valueOf-" + this.value); };
71+
this.toString = function () { throw new ReferenceError ("toString-"+ this.value); };
72+
};
73+
74+
try
75+
{
76+
d = new Date (new Obj (1), new Obj (2));
77+
// Should not be reached.
78+
assert (false);
79+
}
80+
catch (e)
81+
{
82+
assert (e instanceof ReferenceError);
83+
assert (e.message === "valueOf-1");
84+
}

0 commit comments

Comments
 (0)