diff options
-rw-r--r-- | noice.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -287,8 +287,13 @@ readln(void) if (c == KEY_BACKSPACE) { getyx(stdscr, y, x); if (x >= x0) { - ln = realloc(ln, (i - 1) * sizeof(*ln)); - i--; + if (i > 0) { + ln = realloc(ln, (i - 1) * sizeof(*ln)); + i--; + } else { + free(ln); + ln = NULL; + } move(y, x); printw("%c", ' '); move(y, x); |