summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-24 20:36:37 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-24 20:36:37 +0000
commitec19aa60740f126a20db480421538626daf6e0f4 (patch)
treef5b55c945c5284d8a368a8a6d8c617114b6b12b7 /bin
parentac8583e033079afa479f97370b288cf1d3ed41b4 (diff)
realloc fixes: unallocate for next use if realloc fixes; do not incr size;
do not p = realloc(p, ...; ok from ho, cloder
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/print.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c
index 30a05eaf6e9..380668e6961 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.20 2003/08/06 19:09:09 tedu Exp $ */
+/* $OpenBSD: print.c,v 1.21 2003/09/24 20:36:36 deraadt Exp $ */
/* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */
/*
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94";
#else
-static char rcsid[] = "$OpenBSD: print.c,v 1.20 2003/08/06 19:09:09 tedu Exp $";
+static char rcsid[] = "$OpenBSD: print.c,v 1.21 2003/09/24 20:36:36 deraadt Exp $";
#endif
#endif /* not lint */
@@ -168,7 +168,7 @@ printcol(DISPLAY *dp)
int base, chcnt, col, colwidth, num;
int numcols, numrows, row;
- if ( (colwidth = compute_columns(dp, &numcols)) == 0)
+ if ((colwidth = compute_columns(dp, &numcols)) == 0)
return;
/*
* Have to do random access in the linked list -- build a table
@@ -177,11 +177,16 @@ printcol(DISPLAY *dp)
if (dp->entries > lastentries) {
FTSENT **a;
- if ((a =
- realloc(array, dp->entries * sizeof(FTSENT *))) == NULL) {
+ if ((a = realloc(array, dp->entries * sizeof(FTSENT *))) ==
+ NULL) {
+ if (array)
+ free(array);
+ array = NULL;
+ dp->entries = 0;
+ lastentries = -1;
warn(NULL);
printscol(dp);
- return;
+ return;
}
lastentries = dp->entries;
array = a;