NetBSD Problem Report #56243

From  Thu Jun 10 08:45:08 2021
Return-Path: <>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 3D9D31A921F
	for <>; Thu, 10 Jun 2021 08:45:08 +0000 (UTC)
Message-Id: <>
Date: Thu, 10 Jun 2021 08:45:06 +0000 (UTC)
Subject: libcurses: with DISABLE_WCHAR, mvaddch may add at incorrect position
X-Send-Pr-Version: www-1.0

>Number:         56243
>Category:       lib
>Synopsis:       libcurses: with DISABLE_WCHAR, mvaddch may add at incorrect position
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    blymn
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 10 08:50:01 +0000 2021
>Last-Modified:  Wed Apr 27 22:05:01 +0000 2022
>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?



Responsible-Changed-From-To: lib-bug-people->blymn
Responsible-Changed-When: Wed, 27 Apr 2022 07:28:13 +0000
I will claim this bug.

From: "Brett Lymn" <>
Subject: PR/56243 CVS commit: src/lib/libcurses
Date: Wed, 27 Apr 2022 22:04:04 +0000

 Module Name:	src
 Committed By:	blymn
 Date:		Wed Apr 27 22:04:04 UTC 2022

 Modified Files:
 	src/lib/libcurses: move.c

 Log Message:
 Fix for PR 56243
 clear the past EOL flags when moving the cursor - they are no longer
 valid as move cannot put the cursor past the EOL.

 To generate a diff of this commit:
 cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/move.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.