NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/56243: libcurses: with DISABLE_WCHAR, mvaddch may add at incorrect position

>Number:         56243
>Category:       lib
>Synopsis:       libcurses: with DISABLE_WCHAR, mvaddch may add at incorrect position
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 10 08:50:01 +0000 2021
>Originator:     Michael Forney
Consider the following test program:

#include <curses.h>

int main(void) {
	mvaddch(0, COLS - 1, 'X');
	mvaddch(0, 0, 'X');

It should add an 'X' at the top-right and top-left cell. However, adding to the top-right sets the __ISPASTEOL flag for the first line, and this is not cleared during the wmove called from the subsequent mvaddch. When the second mvaddch calls _cursesi_addbyte, it increments the y position since __ISPASTEOL is set, so the 'X' is added at (1, 0) instead of (0, 0).

This bug can also be seen in the vis text editor, since it uses mvaddch to render its UI.
1. Build libcurses with DISABLE_WCHAR=1
2. Compile the test program above.
3. Observe that 'X' is added at position (1, 0) instead of (0, 0).
I think that moving the cursor position should clear the __ISPASTEOL flag.

However, I don't know if it should be cleared from the line corresponding to the old y coordinate, the new y coordinate, or both. I'm also not sure why __ISPASTEOL is a per-line setting. Would it make more sense as a per-window setting, since it is a property of the window's cursor position?

Home | Main Index | Thread Index | Old Index