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) { if (c == KEY_BACKSPACE) {
getyx(stdscr, y, x); getyx(stdscr, y, x);
if (x >= x0) { if (x >= x0) {
i--;
if (i > 0) { if (i > 0) {
ln = xrealloc(ln, (i - 1) * sizeof(*ln)); ln = xrealloc(ln, i * sizeof(*ln));
i--;
} else { } else {
free(ln); free(ln);
ln = NULL; ln = NULL;