summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gunzip.c6
-rw-r--r--src/io.c9
2 files changed, 9 insertions, 6 deletions
diff --git a/src/gunzip.c b/src/gunzip.c
index bed81df..944132e 100644
--- a/src/gunzip.c
+++ b/src/gunzip.c
@@ -149,12 +149,10 @@ struct apk_istream *apk_bstream_gunzip_mpart(struct apk_bstream *bs,
{
struct apk_gzip_istream *gis;
- if (bs == NULL)
- return NULL;
+ if (!bs) return NULL;
gis = malloc(sizeof(struct apk_gzip_istream));
- if (gis == NULL)
- goto err;
+ if (!gis) goto err;
*gis = (struct apk_gzip_istream) {
.is.read = gzi_read,
diff --git a/src/io.c b/src/io.c
index 5ea5e4f..c713107 100644
--- a/src/io.c
+++ b/src/io.c
@@ -427,14 +427,19 @@ struct apk_bstream *apk_bstream_tee(struct apk_bstream *from, int atfd, const ch
struct apk_tee_bstream *tbs;
int fd;
+ if (!from) return NULL;
+
fd = openat(atfd, to, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd < 0)
+ if (fd < 0) {
+ from->close(from, NULL);
return NULL;
+ }
tbs = malloc(sizeof(struct apk_tee_bstream));
- if (tbs == NULL) {
+ if (!tbs) {
close(fd);
+ from->close(from, NULL);
return NULL;
}