Skip to content

Fix wrong type passed for Kitty temp-file medium option - #21

Open
agustux wants to merge 1 commit into
ghostty-org:mainfrom
agustux:fix/kitty-temp-file-medium-type
Open

agustux wants to merge 1 commit into
ghostty-org:mainfrom
agustux:fix/kitty-temp-file-medium-type

Conversation

@agustux

@agustux agustux commented Oct 15, 2026

Copy link
Copy Markdown

Fixes #20

main.c passed &medium_enabled (a bool*) to
GHOSTTY_TERMINAL_OPT_KITTY_IMAGE_MEDIUM_TEMP_FILE, but that option
takes a GhosttyString* (the directory the temp-file medium is
restricted to; NULL disables it). MEDIUM_FILE and MEDIUM_SHARED_MEM
do take bool*, so the shared variable hid the mismatch.

Debug builds panic at startup with "incorrect alignment" in
ghostty_terminal_set, because the library casts the 1-byte bool to
GhosttyString*. In Release builds the library reads a GhosttyString
from a 1-byte object, which is undefined behavior.

This passes a GhosttyString for /tmp to the temp-file option. The
string is copied into the terminal, so a literal is safe. The bool*
options are unchanged, and comments explain the type difference, per
AGENTS.md. The change is limited to main.c; CMakeLists.txt and
libghostty are untouched.

Tested:

  • cmake -B build-dbg -G Ninja -DCMAKE_BUILD_TYPE=Debug then
    cmake --build build-dbg && ./build-dbg/ghostling (Debug) launches
    with no panic. It panicked at main.c:1351 before this change.

Note: We can change /tmp if you'd prefer $TMPDIR to be a different default.

Note: building currently hangs on bin2header.cmake (#16` fixed in #19 ). I tested on top of that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug build panics "incorrect alignment" in ghostty_terminal_set (KITTY_IMAGE_MEDIUM_TEMP_FILE gets bool)

1 participant