=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/fold/fold.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- src/usr.bin/fold/fold.c 2003/06/25 21:19:19 1.9 +++ src/usr.bin/fold/fold.c 2003/09/26 22:22:50 1.10 @@ -1,4 +1,4 @@ -/* $OpenBSD: fold.c,v 1.9 2003/06/25 21:19:19 deraadt Exp $ */ +/* $OpenBSD: fold.c,v 1.10 2003/09/26 22:22:50 tedu Exp $ */ /* $NetBSD: fold.c,v 1.6 1995/09/01 01:42:44 jtc Exp $ */ /*- @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)fold.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: fold.c,v 1.9 2003/06/25 21:19:19 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: fold.c,v 1.10 2003/09/26 22:22:50 tedu Exp $"; #endif /* not lint */ #include @@ -172,12 +172,16 @@ } if (indx + 1 > buf_max) { + int newmax = buf_max + 2048; + char *newbuf; + /* Allocate buffer in LINE_MAX increments */ - buf_max += 2048; - if((buf = realloc(buf, buf_max)) == NULL) { + if ((newbuf = realloc(buf, newmax)) == NULL) { err(1, NULL); /* NOTREACHED */ } + buf = newbuf; + buf_max = newmax; } buf[indx++] = ch; }