aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar sin <sin@2f30.org>2014-10-22 17:57:59 +0100
committerGravatar sin <sin@2f30.org>2014-10-22 17:57:59 +0100
commit8d018e620f159d63c1617a87844d11e51f7a3a23 (patch)
treeddc46e6ef7341c89a5011498f88df7e9d05606df
parent644dd348d6e0a85c9e8ce472e631a2713e07efcc (diff)
downloadnnn-8d018e620f159d63c1617a87844d11e51f7a3a23.tar.gz
realloc() behaves like free() if size is 0
-rw-r--r--noice.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/noice.c b/noice.c
index e4f86a0..638211d 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;