Commit 484a3ff
committed
assert,util: fix TypeError on Maps with null keys
`assert.deepStrictEqual`, `assert.notDeepStrictEqual`, and
`util.isDeepStrictEqual` threw a `TypeError` instead of returning a
result when one Map had a `null` key with an object value, the other
had an object key with a deeply-equal value but no `null` key, and
both maps were the same size.
In that case `mapObjectEquiv` skipped its primitive and `null` key
handling, which was gated on `array.length !== a.size`, and passed
the `null` key (which is `typeof 'object'`) to the object comparator.
That comparator reads `key.constructor` without a null guard, so it
threw. Handle primitive and `null` keys unconditionally, resolving
them directly against the other map.
Fixes: #64433
Signed-off-by: Paul Bouchon <mail@bitpshr.net>1 parent abe2545 commit 484a3ff
2 files changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
840 | | - | |
841 | 840 | | |
842 | 841 | | |
843 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
844 | 847 | | |
845 | 848 | | |
846 | 849 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
424 | 435 | | |
425 | 436 | | |
426 | 437 | | |
| |||
0 commit comments