Handle realloc() failure correctly.

This commit is contained in:
Tim J. Robbins 2003-10-16 07:07:20 +00:00
parent b03587f06a
commit c5bc87095b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121124

View file

@ -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)