From 8d018e620f159d63c1617a87844d11e51f7a3a23 Mon Sep 17 00:00:00 2001 From: sin Date: Wed, 22 Oct 2014 17:57:59 +0100 Subject: [PATCH] realloc() behaves like free() if size is 0 --- noice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noice.c b/noice.c index e4f86a03..638211d8 100644 --- a/noice.c +++ b/noice.c @@ -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;