diff options
author | kientzle <kientzle@FreeBSD.org> | 2005-09-21 04:25:06 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2005-09-21 04:25:06 +0000 |
commit | dcb8de96ab47d1932ce313adbac5a673210b1c91 (patch) | |
tree | 6f61f48765d8080ef9566d9cbfc0f3e97cefd834 /lib/libarchive/archive_read.c | |
parent | b035b8b7b3780581ed55ea9ca0660c0af57f5a5b (diff) | |
download | FreeBSD-src-dcb8de96ab47d1932ce313adbac5a673210b1c91.zip FreeBSD-src-dcb8de96ab47d1932ce313adbac5a673210b1c91.tar.gz |
Add a lot of error checks, based on the patches provided by Dan Lukes.
Also fixes a memory leak reported by Andrew Turner.
PR: bin/83476
Thanks to: Dan Lukes, Andrew Turner
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r-- | lib/libarchive/archive_read.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c index 7e81fb2..1d8f86d 100644 --- a/lib/libarchive/archive_read.c +++ b/lib/libarchive/archive_read.c @@ -58,6 +58,10 @@ archive_read_new(void) char *nulls; a = malloc(sizeof(*a)); + if (a == NULL) { + archive_set_error(a, ENOMEM, "Can't allocate archive object"); + return (NULL); + } memset(a, 0, sizeof(*a)); a->user_uid = geteuid(); @@ -66,6 +70,11 @@ archive_read_new(void) a->null_length = 1024; nulls = malloc(a->null_length); + if (nulls == NULL) { + archive_set_error(a, ENOMEM, "Can't allocate archive object 'nulls' element"); + free(a); + return (NULL); + } memset(nulls, 0, a->null_length); a->nulls = nulls; |