From 6508a1ecdc64abad3ecf2ad114bbca21518c1506 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Tue, 19 Sep 2006 22:11:43 +0000 Subject: [PATCH] Add missing parentheses to fix a segmentation fault that is easily reproducable with `jot -s " " 400 1 | column -t'. The bug was present in the the original CSRG 'column -t' added in 1989. --- usr.bin/column/column.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c index ccaa8247ca29..ca2837dd5a68 100644 --- a/usr.bin/column/column.c +++ b/usr.bin/column/column.c @@ -247,10 +247,10 @@ maketbl(void) (cols[coloff] = wcstok(p, separator, &last)); p = NULL) if (++coloff == maxcols) { - if (!(cols = realloc(cols, (u_int)maxcols + - DEFCOLS * sizeof(char *))) || + if (!(cols = realloc(cols, ((u_int)maxcols + + DEFCOLS) * sizeof(char *))) || !(lens = realloc(lens, - (u_int)maxcols + DEFCOLS * sizeof(int)))) + ((u_int)maxcols + DEFCOLS) * sizeof(int)))) err(1, NULL); memset((char *)lens + maxcols * sizeof(int), 0, DEFCOLS * sizeof(int));