From af42d4786600517543c829652cc516746deeda93 Mon Sep 17 00:00:00 2001 From: Kris Kennaway Date: Mon, 3 Sep 2001 05:57:06 +0000 Subject: [PATCH] Check for malloc failure in a couple of cases MFC after: 2 weeks --- lib/libstand/gzipfs.c | 4 ++++ lib/libstand/zipfs.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/libstand/gzipfs.c b/lib/libstand/gzipfs.c index bcf0acea920..61e72154b76 100644 --- a/lib/libstand/gzipfs.c +++ b/lib/libstand/gzipfs.c @@ -179,6 +179,8 @@ zf_open(const char *fname, struct open_file *f) /* Construct new name */ zfname = malloc(strlen(fname) + 4); + if (zfname == NULL) + return(ENOMEM); sprintf(zfname, "%s.gz", fname); /* Try to open the compressed datafile */ @@ -200,6 +202,8 @@ zf_open(const char *fname, struct open_file *f) /* Allocate a z_file structure, populate it */ zf = malloc(sizeof(struct z_file)); + if (zf == NULL) + return(ENOMEM); bzero(zf, sizeof(struct z_file)); zf->zf_rawfd = rawfd; diff --git a/lib/libstand/zipfs.c b/lib/libstand/zipfs.c index bcf0acea920..61e72154b76 100644 --- a/lib/libstand/zipfs.c +++ b/lib/libstand/zipfs.c @@ -179,6 +179,8 @@ zf_open(const char *fname, struct open_file *f) /* Construct new name */ zfname = malloc(strlen(fname) + 4); + if (zfname == NULL) + return(ENOMEM); sprintf(zfname, "%s.gz", fname); /* Try to open the compressed datafile */ @@ -200,6 +202,8 @@ zf_open(const char *fname, struct open_file *f) /* Allocate a z_file structure, populate it */ zf = malloc(sizeof(struct z_file)); + if (zf == NULL) + return(ENOMEM); bzero(zf, sizeof(struct z_file)); zf->zf_rawfd = rawfd;