about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpara <para@danwin1210.de>2024-03-01 17:13:39 +0200
committerJune McEnroe <june@causal.agency>2024-03-21 21:38:43 -0400
commit492b7f7b9406b8e460c4a64aed45c70a8a8e152d (patch)
tree5bbdb937d987852702e494ec8fa4eabc53fc1583
parentBe specific about which file is at an unexpected end (diff)
downloadcatgirl-492b7f7b9406b8e460c4a64aed45c70a8a8e152d.tar.gz
catgirl-492b7f7b9406b8e460c4a64aed45c70a8a8e152d.zip
Fix style character handling bug 2.2a
In some ncurses implementations[1], waddnstr returns ERR when len is 0.
This happens in styleAdd() whenever there is a sequence of more than 1
style character in a row.

This may result in visual bugs, the most notable of which is being
unable to see the messages that mention you (due to the "\26\3"
sequence).

In order to properly handle multiple style characters in a row, waddnstr
should only be called when len is greater than 0.

Tested on Alpine Linux, using the official ncurses package.
[1]https://invisible-island.net/ncurses
Diffstat (limited to '')
-rw-r--r--window.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/window.c b/window.c
index 00041aa..f700fd7 100644
--- a/window.c
+++ b/window.c
@@ -147,6 +147,7 @@ static int styleAdd(WINDOW *win, struct Style init, const char *str) {
 	struct Style style = init;
 	while (*str) {
 		size_t len = styleParse(&style, &str);
+		if (!len) continue;
 		wattr_set(win, uiAttr(style), uiPair(style), NULL);
 		if (waddnstr(win, str, len) == ERR)
 			return -1;
5 15:38:14 +0200'>2019-06-05tests: successfully validate rc versionsChristian Hesse 2019-06-05git: update to v2.21.0Christian Hesse 2019-06-05ui-ssdiff: ban strncat()Christian Hesse 2019-06-05global: make 'char *path' const where possibleChristian Hesse 2019-05-20ui-shared: restrict to 15 levelsJason A. Donenfeld 2019-02-23ui-diff,ui-tag: don't use htmlf with non-formatted stringsChris Mayo 2019-02-23ui-ssdiff: resolve HTML5 validation errorsChris Mayo 2019-01-03filters: migrate from luacrypto to luaosslJason A. Donenfeld 2019-01-02ui-shared: fix broken sizeof in title setting and rewriteJason A. Donenfeld 2018-12-09git: update to v2.20.0Christian Hesse 2018-11-25ui-blame: set repo for sbJason A. Donenfeld 2018-11-25auth-filter: pass url with query string attachedJason A. Donenfeld 2018-11-21git: use xz compressed archive for downloadChristian Hesse 2018-10-12git: update to v2.19.1Christian Hesse 2018-09-11ui-ssdiff: ban strcat()Christian Hesse 2018-09-11ui-ssdiff: ban strncpy()Christian Hesse 2018-09-11ui-shared: ban strcat()Christian Hesse 2018-09-11ui-patch: ban sprintf()Christian Hesse 2018-09-11ui-log: ban strncpy()Christian Hesse 2018-09-11ui-log: ban strcpy()Christian Hesse 2018-09-11parsing: ban sprintf()Christian Hesse 2018-09-11parsing: ban strncpy()Christian Hesse 2018-08-28filters: generate anchor links from markdownChristian Hesse 2018-08-03Bump version.Jason A. Donenfeld 2018-08-03clone: fix directory traversalJason A. Donenfeld 2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev