Commit 084f93f
Null loaded dict entries after a failed truncate
PersistedSymbolDict.openExisting frees the loaded-entries buffer in the
truncate-failure branch, then calls ff.close(fd). If that close threw, the
enclosing catch re-freed the same buffer -- a double-free -- because,
unlike the bad-magic branch, this branch did not null the pointer first.
Null entriesAddr/entriesLen right after freeing them, matching the buf
discipline above, so the catch's guard skips the second free. Correct the
catch comment, which wrongly claimed nothing between the malloc and the
return could throw -- the truncate branch's free-then-close is exactly
such a point.
This is defensive hardening: FilesFacade.close returns a status code and
never throws (the native close never raises), so the path is unreachable
today, but the nulling keeps it safe against a future facade or edit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 76fe4f1 commit 084f93f
1 file changed
Lines changed: 9 additions & 4 deletions
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
611 | 615 | | |
612 | 616 | | |
613 | 617 | | |
| |||
617 | 621 | | |
618 | 622 | | |
619 | 623 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
624 | 629 | | |
625 | 630 | | |
626 | 631 | | |
| |||
0 commit comments