mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
Handle realloc() failure correctly.
This commit is contained in:
parent
b03587f06a
commit
c5bc87095b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121124
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue