Pre-allocate buffer to avoid core dump in corner cases.

PR:		2968
Submitted by:	Gareth McCaughan <gjm11@dpmms.cam.ac.uk>
This commit is contained in:
Jonathan Lemon 1997-08-21 03:41:41 +00:00
parent 0426565f90
commit dc3001cf35
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28478

View File

@ -42,7 +42,7 @@ static char copyright[] =
static char sccsid[] = "@(#)fmt.c 8.1 (Berkeley) 7/20/93";
#else
static const char rcsid[] =
"$Id$";
"$Id: fmt.c,v 1.9 1997/07/03 07:19:46 charnier Exp $";
#endif
#endif /* not lint */
@ -162,7 +162,11 @@ fmt(fi)
register char *cp, *cp2, cc;
register int c, col;
#define CHUNKSIZE 1024
static int lbufsize = 0, cbufsize = 0;
static int lbufsize = 0, cbufsize = CHUNKSIZE;
canonb = malloc(CHUNKSIZE);
if (canonb == 0)
abort();
if (center) {
linebuf = malloc(BUFSIZ);