Repository navigation
Commit b433a9b
committed
[Fix]
The `allowEmptyArrays` fast path returned early on any array with
`length === 0`, before the loop that records the cyclic-reference
bookkeeping and serializes own keys.
An empty array carrying own enumerable properties
(including one that closes a cycle)
was therefore short-circuited to `[]`,
silently dropping those keys and bypassing the
`RangeError("Cyclic object value")` guard.
Only short-circuit when the array has no own keys.stringify: do not let allowEmptyArrays skip cycle detection (or drop own keys) on an empty array with own properties1 parent f3dc5b0 commit b433a9b
2 files changed
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
469 | 502 | | |
470 | 503 | | |
471 | 504 | | |
| |||
0 commit comments