Skip to content

Commit 19312f8

Browse files
committed
Fix NaN normalization bug for packed tval
NaN normalization check should use a full NaN check to decide when to normalize, even when using partial NaN initialization. The fix here is to switch to full NaN initialization in general.
1 parent 1827a77 commit 19312f8

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src-input/duk_dblunion.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ typedef union duk_double_union duk_double_union;
322322
} while (0)
323323

324324
#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL(u) do { \
325-
if (DUK__DBLUNION_IS_NAN_NOTFULL((u))) { \
325+
/* Check must be full. */ \
326+
if (DUK__DBLUNION_IS_NAN_FULL((u))) { \
326327
DUK__DBLUNION_SET_NAN_NOTFULL((u)); \
327328
} \
328329
} while (0)
@@ -334,12 +335,11 @@ typedef union duk_double_union duk_double_union;
334335
*/
335336

336337
#if defined(DUK_USE_PACKED_TVAL)
337-
#if defined(DUK_USE_FULL_TVAL)
338338
#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u) DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL((u))
339339
#define DUK_DBLUNION_IS_NAN(u) DUK__DBLUNION_IS_NAN_FULL((u))
340340
#define DUK_DBLUNION_IS_NORMALIZED_NAN(u) DUK__DBLUNION_IS_NORMALIZED_NAN_FULL((u))
341341
#define DUK_DBLUNION_SET_NAN(d) DUK__DBLUNION_SET_NAN_FULL((d))
342-
#else
342+
#if 0
343343
#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u) DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL((u))
344344
#define DUK_DBLUNION_IS_NAN(u) DUK__DBLUNION_IS_NAN_NOTFULL((u))
345345
#define DUK_DBLUNION_IS_NORMALIZED_NAN(u) DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL((u))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*---
2+
{
3+
"custom": true
4+
}
5+
---*/
6+
7+
/*===
8+
NaN
9+
done
10+
===*/
11+
12+
try {
13+
var val = CBOR.decode(new Uint8Array([ 0xfb, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ]));
14+
print(val);
15+
} catch (e) {
16+
print(e.stack || e);
17+
}
18+
19+
print('done');

0 commit comments

Comments
 (0)