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:
Ian Dowse 2006-09-19 22:11:43 +00:00
parent d7b167b57b
commit 6508a1ecdc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162453

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