mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Fix segfault in readln()
This could be reproduced simply by doing: [TAB] and backspacing a few times.
This commit is contained in:
parent
330adc995f
commit
cfd530b167
5
noice.c
5
noice.c
|
@ -287,8 +287,13 @@ readln(void)
|
||||||
if (c == KEY_BACKSPACE) {
|
if (c == KEY_BACKSPACE) {
|
||||||
getyx(stdscr, y, x);
|
getyx(stdscr, y, x);
|
||||||
if (x >= x0) {
|
if (x >= x0) {
|
||||||
|
if (i > 0) {
|
||||||
ln = realloc(ln, (i - 1) * sizeof(*ln));
|
ln = realloc(ln, (i - 1) * sizeof(*ln));
|
||||||
i--;
|
i--;
|
||||||
|
} else {
|
||||||
|
free(ln);
|
||||||
|
ln = NULL;
|
||||||
|
}
|
||||||
move(y, x);
|
move(y, x);
|
||||||
printw("%c", ' ');
|
printw("%c", ' ');
|
||||||
move(y, x);
|
move(y, x);
|
||||||
|
|
Loading…
Reference in a new issue