summaryrefslogtreecommitdiffstats
path: root/bin/ls/print.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-10-16 07:07:20 +0000
committertjr <tjr@FreeBSD.org>2003-10-16 07:07:20 +0000
commit05ad019d7bf508effb16a8c66f1749674b8ec983 (patch)
treed08e5c1d4e77a8ee2b7393a746af0067373d89c3 /bin/ls/print.c
parent0dd6703d54f1ef4f4db724f876ae5354ffd92d50 (diff)
downloadFreeBSD-src-05ad019d7bf508effb16a8c66f1749674b8ec983.zip
FreeBSD-src-05ad019d7bf508effb16a8c66f1749674b8ec983.tar.gz
Handle realloc() failure correctly.
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r--bin/ls/print.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c
index ae1f9db..fb8d718 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -264,6 +264,7 @@ printcol(const DISPLAY *dp)
static FTSENT **array;
static int lastentries = -1;
FTSENT *p;
+ FTSENT **narray;
int base;
int chcnt;
int cnt;
@@ -286,12 +287,14 @@ printcol(const DISPLAY *dp)
* of pointers.
*/
if (dp->entries > lastentries) {
- lastentries = dp->entries;
- if ((array =
+ if ((narray =
realloc(array, dp->entries * sizeof(FTSENT *))) == NULL) {
warn(NULL);
printscol(dp);
+ return;
}
+ lastentries = dp->entries;
+ array = narray;
}
for (p = dp->list, num = 0; p; p = p->fts_link)
if (p->fts_number != NO_PRINT)
OpenPOWER on IntegriCloud