Browse Source

Merge branch 'fix-push-nan-msvc'

pull/195/head
Sami Vaarala 10 years ago
parent
commit
56f4c43468
  1. 3
      RELEASES.rst
  2. 7
      src/duk_api_stack.c

3
RELEASES.rst

@ -919,6 +919,9 @@ Planned
1.3.0 (2015-XX-XX) 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) 2.0.0 (XXXX-XX-XX)
------------------ ------------------

7
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_EXTERNAL void duk_push_nan(duk_context *ctx) {
duk_hthread *thr; duk_hthread *thr;
duk_tval *tv_slot; duk_tval *tv_slot;
duk_double_t d; duk_double_union du;
DUK_ASSERT(ctx != NULL); DUK_ASSERT(ctx != NULL);
thr = (duk_hthread *) ctx; thr = (duk_hthread *) ctx;
DUK__CHECK_SPACE(); DUK__CHECK_SPACE();
d = DUK_DOUBLE_NAN; DUK_DBLUNION_SET_NAN(&du);
DUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));
tv_slot = thr->valstack_top++; 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) { DUK_EXTERNAL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len) {

Loading…
Cancel
Save