]> git.donarmstrong.com Git - samtools.git/commitdiff
Return NULL from _razf_open() (and hence razf_open()/razf_open2())
authorOn behalf of John Marshall <lh3@sanger.ac.uk>
Fri, 4 Sep 2009 16:46:25 +0000 (16:46 +0000)
committerOn behalf of John Marshall <lh3@sanger.ac.uk>
Fri, 4 Sep 2009 16:46:25 +0000 (16:46 +0000)
when opening the file fails.

razf.c

diff --git a/razf.c b/razf.c
index a5e8f5161a8d0780a820556e0e6640fd9762bb12..ea4e37d5717a102b77801e254e4828ac8f3c8f14 100644 (file)
--- a/razf.c
+++ b/razf.c
@@ -409,6 +409,7 @@ static inline RAZF* _razf_open(const char *filename, const char *mode, int _load
 #else
                fd = open(filename, O_RDONLY);
 #endif
+               if(fd < 0) return NULL;
                rz = razf_open_r(fd, _load_index);
        } else if(strstr(mode, "w")){
 #ifdef _WIN32
@@ -416,6 +417,7 @@ static inline RAZF* _razf_open(const char *filename, const char *mode, int _load
 #else
                fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 #endif
+               if(fd < 0) return NULL;
                rz = razf_open_w(fd);
        } else return NULL;
        return rz;