Skip to content

Fix crash when termcap is used and cursor_left is unavailable#77

Merged
troglobit merged 1 commit intotroglobit:masterfrom
tweqx:termcap-unknown-term
Feb 16, 2026
Merged

Fix crash when termcap is used and cursor_left is unavailable#77
troglobit merged 1 commit intotroglobit:masterfrom
tweqx:termcap-unknown-term

Conversation

@tweqx
Copy link
Contributor

@tweqx tweqx commented Feb 14, 2026

If termcap is used and the cursor_left terminal capability is not available, editline will segfault on most actions: for instance, deleting a character.

Summary of the changes:

  • tgetent returns -1 if the terminfo database cannot be loaded, 0 if the terminal name could not be found in the database and 1 on success. I updated the return value check.
  • if tgetstr("le", &bp) returns NULL (the cursor_left capability is not available), it is preferable to keep backspace to its default value rather than assigning it to NULL. This is what causes the segfault.

Copy link
Owner

@troglobit troglobit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@troglobit troglobit merged commit 2e0504d into troglobit:master Feb 16, 2026
2 checks passed
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.

2 participants