aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJia Zhouyang <jiazhouyang@nudt.edu.cn>2018-03-04 12:50:49 +0000
committerGitHub <noreply@github.com>2018-03-04 12:50:49 +0000
commit996287e2fd03e0050aaaa64398884b1b547a56d0 (patch)
treefb1a5f31f88f5a6c8ae82eff134529748cf67688
parentAdd error handling for chdir (diff)
downloadw3m-996287e2fd03e0050aaaa64398884b1b547a56d0.tar.gz
w3m-996287e2fd03e0050aaaa64398884b1b547a56d0.zip
Add error handling code for fopen
Check the return value of fopen, and add proper error handling code.
-rw-r--r--file.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/file.c b/file.c
index 9b0e947..0333e9a 100644
--- a/file.c
+++ b/file.c
@@ -611,8 +611,10 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu)
if(w3m_reqlog){
FILE *ff;
ff = fopen(w3m_reqlog, "a");
- Strfputs(tmp, ff);
- fclose(ff);
+ if(ff){
+ Strfputs(tmp, ff);
+ fclose(ff);
+ }
}
if (src)
Strfputs(tmp, src);
@@ -7580,6 +7582,8 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf)
tmp = Sprintf("<img src=\"%s\"><br><br>", html_quote(image.url));
tmpf = tmpfname(TMPF_SRC, ".html");
src = fopen(tmpf->ptr, "w");
+ if (src == NULL)
+ return NULL;
newBuf->mailcap_source = tmpf->ptr;
init_stream(&f, SCM_LOCAL, newStrStream(tmp));