tech-userlevel archive

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

curses: printw displays multibyte string wrong if ASAN is not used



Hello,

printw() does output multibyte strings only correctly when compiled with ASAN.  This likely indicates a curses internal data corruption which has no effect with the different memory layout used by ASAN.

Attached is a archive for reproducing the issue (in an UTF-8 locale).

The output is "äöüÃ" without ASAN and "äöüß" with ASAN.

The contents (must be UTF-8 encoded) are

$ cat Makefile                                                                                                                                                                                 
LDFLAGS=-lcurses
CFLAGS=-g #-fsanitize=address

all: main

clean:
        rm -f main

$ cat main.c                                                                                                                                                                                   
#include <locale.h>
#include <curses.h>

int
main()
{
        char *mbs = "äöüß";

        setlocale(LC_ALL, "");
        initscr();
        printw("%s\n", mbs);
        refresh();
        getch();
        endwin();
        return 0;
}



Home | Main Index | Thread Index | Old Index