From 0c5ba09aa301e242881302613882c5604f1a908b Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Tue, 7 Apr 2015 19:49:47 +0300 Subject: [PATCH 1/2] Fix potentially unnormalized NaN in duk_push_nan() --- src/duk_api_stack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/duk_api_stack.c b/src/duk_api_stack.c index 18b35dc1..b49fd0ea 100644 --- a/src/duk_api_stack.c +++ b/src/duk_api_stack.c @@ -2900,14 +2900,15 @@ DUK_EXTERNAL void duk_push_uint(duk_context *ctx, duk_uint_t val) { DUK_EXTERNAL void duk_push_nan(duk_context *ctx) { duk_hthread *thr; duk_tval *tv_slot; - duk_double_t d; + duk_double_union du; DUK_ASSERT(ctx != NULL); thr = (duk_hthread *) ctx; DUK__CHECK_SPACE(); - d = DUK_DOUBLE_NAN; + DUK_DBLUNION_SET_NAN(&du); + DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du)); tv_slot = thr->valstack_top++; - DUK_TVAL_SET_NUMBER(tv_slot, d); + DUK_TVAL_SET_NUMBER(tv_slot, du.d); } DUK_EXTERNAL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len) { From 2a16523da28a8d11015df9d8f1a054bfc5d36e10 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Tue, 7 Apr 2015 20:09:59 +0300 Subject: [PATCH 2/2] Releases: duk_push_nan() --- RELEASES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASES.rst b/RELEASES.rst index 1ec7d8e8..dbb58e68 100644 --- a/RELEASES.rst +++ b/RELEASES.rst @@ -919,6 +919,9 @@ Planned 1.3.0 (2015-XX-XX) ------------------ +* Fix duk_push_nan() NaN normalization bug which caused segfaults when using + MSVC on x86 and potentially on other 32-bit platforms (GH-168) + 2.0.0 (XXXX-XX-XX) ------------------