summaryrefslogtreecommitdiff
path: root/usr.bin/indent/io.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-09-26 22:24:10 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-09-26 22:24:10 +0000
commit17738dcbee8bacfd8a68cd4375820c4947ff55d6 (patch)
tree37af77e881cde2f3b424047b2aabd080ab96328b /usr.bin/indent/io.c
parent620a0222f490c8fe0d8dfc7b15279733cfed0593 (diff)
better realloc. ok deraadt@ henning@
Diffstat (limited to 'usr.bin/indent/io.c')
-rw-r--r--usr.bin/indent/io.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/indent/io.c b/usr.bin/indent/io.c
index a555768ace5..73ed875ea58 100644
--- a/usr.bin/indent/io.c
+++ b/usr.bin/indent/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.7 2003/06/03 02:56:09 millert Exp $ */
+/* $OpenBSD: io.c,v 1.8 2003/09/26 22:23:28 tedu Exp $ */
/*
* Copyright (c) 1985 Sun Microsystems, Inc.
@@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: io.c,v 1.7 2003/06/03 02:56:09 millert Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.8 2003/09/26 22:23:28 tedu Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -337,7 +337,7 @@ compute_label_target()
void
fill_buffer()
{ /* this routine reads stuff from the input */
- char *p;
+ char *p, *buf2;
int i;
FILE *f = input;
@@ -353,9 +353,10 @@ fill_buffer()
if (p >= in_buffer_limit) {
int size = (in_buffer_limit - in_buffer) * 2 + 10;
int offset = p - in_buffer;
- in_buffer = (char *) realloc(in_buffer, size);
- if (in_buffer == NULL)
+ buf2 = realloc(in_buffer, size);
+ if (buf2 == NULL)
errx(1, "input line too long");
+ in_buffer = buf2;
p = in_buffer + offset;
in_buffer_limit = in_buffer + size - 2;
}