mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-29 12:44:53 +01: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 New Issue
Block a user