Files
LLeMbas-TTY/term/src
zakradandBenoit de Chezelles d6e1859782 fix(term): avoid divide-by-zero crashes in inline image placement (#7872)
assign_image_to_cells contained two unguarded divisions that could panic
with 'attempt to divide by zero' and take down the pane (and, under the mux,
the pane's reader thread):

1. A Kitty graphics escape requesting a zero-sized placement (eg: an explicit
   w=0/h=0, or a source origin outside the image bounds) yields a
   draw_width/draw_height of 0, used as a divisor when sizing the image.
   This is the case reported in #6344.

2. Displaying a cell-sized image (one without explicit c=/r=) on a pane whose
   pty reported no pixel dimensions makes cell_pixel_width/height 0, which is
   then used as a divisor. A zero pixel size is the default PtySize and is what
   tmux/headless domains report, so a perfectly valid image crashes there.

Guard both: refuse the placement when the drawable region or the cell pixel
size is zero.
The error flows into the existing logging handlers for the Kitty, iTerm and
Sixel paths, so no callers change.
Real GUI panes always have a non-zero pixel size, so valid images are
unaffected.

Adds regression tests for both cases (each panics on main, passes with the
fix) and enables kitty graphics in the test terminal config (off by default)
so the path is exercised.

Closes #6344

---------

Co-authored-by: Benoit de Chezelles <benoit.dechezelles@gmail.com>
2026-06-21 22:45:33 +02:00
..