Skip to content

Commit d06bdb4

Browse files
committed
fix(ghostty): make GhosttyTerminal.free() idempotent
ghostty 1.3's libghostty-vt dispatches effect callbacks via an indirect call through the function table. Calling free() twice on the same instance (e.g. manual wasmTerm.free() followed by term.dispose()) drove ghostty_terminal_free into freed memory and surfaced as a call_indirect signature mismatch on the second call. Gate on this.handle at entry and zero it after the free. Recovers the two #141 regression tests that started failing after the merge to ghostty 1.3.
1 parent 3836409 commit d06bdb4

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

lib/ghostty.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ export class GhosttyTerminal {
10561056
}
10571057

10581058
free(): void {
1059+
if (!this.handle) return;
10591060
if (this.callbackRegistry) {
10601061
this.callbackRegistry.instancesByHandle.delete(this.handle);
10611062
}
@@ -1072,6 +1073,7 @@ export class GhosttyTerminal {
10721073
this.renderHandle = 0;
10731074
}
10741075
this.exports.ghostty_terminal_free(this.handle);
1076+
this.handle = 0;
10751077
}
10761078

10771079
// ==========================================================================

0 commit comments

Comments
 (0)