prevent off by 1 - iomenu - interactive terminal-based selection menu
(HTM) git clone git://bitreich.org/iomenu git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/iomenu
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit e5026f5e15dba1cd072196edf8a1ead240ab4b2c
(DIR) parent e3bca30c0b12f79deb675e0e7bd36917226e3dff
(HTM) Author: Josuah Demangeon <mail@josuah.net>
Date: Fri, 8 Dec 2017 10:18:13 +0100
prevent off by 1
Diffstat:
M iomenu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/iomenu.c b/iomenu.c
@@ -75,9 +75,9 @@ split_lines(char *buf)
linec = 1;
for (b = buf; (b = strchr(b, '\n')) != NULL && b[1] != '\0'; b++)
linec++;
- if ((lv = linev = calloc(linec, sizeof (char **))) == NULL)
+ if ((lv = linev = calloc(linec + 1, sizeof (char **))) == NULL)
die("calloc");
- if ((mv = matchv = calloc(linec, sizeof (char **))) == NULL)
+ if ((mv = matchv = calloc(linec + 1, sizeof (char **))) == NULL)
die("calloc");
*mv = *lv = b = buf;
while ((b = strchr(b, '\n')) != NULL) {