buffer.c: off by one - iomenu - interactive terminal-based selection menu HTML git clone git://bitreich.org/iomenu git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/iomenu DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit afbe8d1e4630f1e1ca5f55d8f2a61ef63956494c DIR parent 972969f0568ff78ac41d72a942440859af004ad2 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Wed, 1 Nov 2017 17:15:48 +0100 buffer.c: off by one Diffstat: M buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- DIR diff --git a/buffer.c b/buffer.c @@ -50,17 +50,17 @@ split_lines(char *buf) linec++; if (!linec) linec = 1; - if (!(lv = linev = calloc(linec, sizeof (char **)))) + if (!(lv = linev = calloc(linec + 1, sizeof (char **)))) die("calloc"); - if (!(mv = matchv = calloc(linec, sizeof (char **)))) { + if (!(mv = matchv = calloc(linec + 1, sizeof (char **)))) { free(linev); die("calloc"); } *mv = *lv = b = buf; while ((b = strchr(b, '\n'))) { - *b++ = '\0'; + *b = '\0'; mv++, lv++; - *mv = *lv = b; + *mv = *lv = ++b; } }