Skip to content

BUG: Division by zero potential in imageRows when cellHeight is 0 #865

@andrinoff

Description

@andrinoff

Describe the bug

In imageRows() (view/html.go:274-278), cellHeight from getCellHeightFromFd() could return 0 if the terminal doesn't support the ioctl query. The division (h + cellHeight - 1) / cellHeight would then panic with division by zero.

To reproduce

  1. Run matcha in a terminal that doesn't report cell size via ioctl
  2. Open an email with an inline image
  3. Observe division by zero panic

Expected behavior

Check cellHeight > 0 before dividing, default to a reasonable fallback (e.g. 16px).

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions