Skip to content

fix: clipboard request leak when embedder dismisses confirmation dialog #185

@daiimus

Description

@daiimus

Summary

In embedded.zig:800-834, when completeClipboardRequest throws UnsafePaste or UnauthorizedPaste, the state pointer is NOT freed (the defer is skipped via early return). The expectation is the embedder will call ghostty_surface_complete_clipboard_request again with the confirmation.

If the embedder dismisses the confirmation dialog without calling back, the ClipboardRequest allocation leaks permanently.

Fix

Either:

  1. Provide an explicit ghostty_surface_cancel_clipboard_request(state) API for the dismiss case.
  2. Track outstanding clipboard requests on the surface and clean them up in deinit.

Severity

MEDIUM — Memory leak per dismissed clipboard confirmation. Accumulates over time.

Source

Identified during code review of daiimus/ghostty:ios-external-backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2-mediumDegraded experience, workaround existsupstreamBug exists in upstream ghosttyzig-forkRequires Ghostty fork changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions