Commit aaf38ec
committed
Refuse to resume a partial array/map with the other of skip()/unpack()
skip() and unpack() share one Unpacker._unpack() state machine and the
same context, but a skip() call never populates a container frame's
object slot, since it has no Python object to build there. If skip()
leaves an array or map open because the buffer ran out mid-container,
and the next call resumes it through unpack() instead, unpack() treats
that slot as if it already held a real list or dict and crashes trying
to append into it.
Track which of the two last made progress on an in-progress container
and reject switching to the other one with a clear ValueError instead
of segfaulting. Resuming with the same method that started the parse
still works exactly as before.
Fixes #7341 parent 9f4909c commit aaf38ec
2 files changed
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
323 | 328 | | |
324 | 329 | | |
325 | 330 | | |
| |||
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
476 | 489 | | |
477 | 490 | | |
478 | 491 | | |
| |||
486 | 499 | | |
487 | 500 | | |
488 | 501 | | |
| 502 | + | |
489 | 503 | | |
490 | 504 | | |
| 505 | + | |
491 | 506 | | |
492 | 507 | | |
493 | 508 | | |
| |||
497 | 512 | | |
498 | 513 | | |
499 | 514 | | |
| 515 | + | |
500 | 516 | | |
501 | 517 | | |
502 | 518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
66 | 108 | | |
67 | 109 | | |
68 | 110 | | |
| |||
0 commit comments