Skip to content

Commit fd180c3

Browse files
authored
Merge pull request libarchive#1759 from obiwac/fix-1754
libarchive: Handle a `calloc` returning NULL (fixes libarchive#1754)
2 parents 1385cd9 + bff38ef commit fd180c3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

libarchive/archive_write.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ __archive_write_allocate_filter(struct archive *_a)
201201
struct archive_write_filter *f;
202202

203203
f = calloc(1, sizeof(*f));
204+
205+
if (f == NULL)
206+
return (NULL);
207+
204208
f->archive = _a;
205209
f->state = ARCHIVE_WRITE_FILTER_STATE_NEW;
206210
if (a->filter_first == NULL)
@@ -548,6 +552,10 @@ archive_write_open2(struct archive *_a, void *client_data,
548552
a->client_data = client_data;
549553

550554
client_filter = __archive_write_allocate_filter(_a);
555+
556+
if (client_filter == NULL)
557+
return (ARCHIVE_FATAL);
558+
551559
client_filter->open = archive_write_client_open;
552560
client_filter->write = archive_write_client_write;
553561
client_filter->close = archive_write_client_close;

0 commit comments

Comments
 (0)