Commit ff87d86
fix: size dict elements buffer to HashMap capacity, not len (#1646)
When materializing a Felt252Dict value, the elements buffer was
arena-allocated with room for `map.len()` slots. The runtime's
`dict_get` only grows the buffer once the backing HashMap is full, so a
runtime insert of a new key could write one slot past the end of the
buffer and corrupt the arena.
Allocate the buffer using the HashMap's capacity (read after `reserve`,
which usually over-allocates) so there is always room for the runtime to
fill every slot the HashMap can hold.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1c3473a commit ff87d86
1 file changed
Lines changed: 12 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
374 | 384 | | |
375 | 385 | | |
376 | 386 | | |
377 | 387 | | |
378 | | - | |
| 388 | + | |
379 | 389 | | |
380 | 390 | | |
381 | 391 | | |
382 | 392 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | 393 | | |
392 | 394 | | |
393 | 395 | | |
| |||
0 commit comments