From: On behalf of John Marshall Date: Fri, 4 Sep 2009 16:46:25 +0000 (+0000) Subject: Return NULL from _razf_open() (and hence razf_open()/razf_open2()) X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a871942229ef1770da3edec7e1b57194456f4f5d;p=samtools.git Return NULL from _razf_open() (and hence razf_open()/razf_open2()) when opening the file fails. --- diff --git a/razf.c b/razf.c index a5e8f51..ea4e37d 100644 --- 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;