realloc() behaves like free() if size is 0

This commit is contained in:
sin 2014-10-22 17:57:59 +01:00
parent 644dd348d6
commit 8d018e620f

View file

@ -366,9 +366,9 @@ readln(void)
if (c == KEY_BACKSPACE) {
getyx(stdscr, y, x);
if (x >= x0) {
i--;
if (i > 0) {
ln = xrealloc(ln, (i - 1) * sizeof(*ln));
i--;
ln = xrealloc(ln, i * sizeof(*ln));
} else {
free(ln);
ln = NULL;