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.
This commit is contained in:
iedowse 2006-09-19 22:11:43 +00:00
parent fc7fc7fa1c
commit 750ab68ba1

View File

@ -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));