Add error handling code for fopen

Check the return code of fopen, and return when it fails.
This commit is contained in:
Jia Zhouyang
2018-03-04 20:57:08 +08:00
committed by GitHub
parent 996287e2fd
commit 7a49f77b1e

4
url.c
View File

@@ -1752,6 +1752,8 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
write(sock, tmp->ptr, tmp->length);
if(w3m_reqlog){
FILE *ff = fopen(w3m_reqlog, "a");
if (ff == NULL)
return uf;
if (sslh)
fputs("HTTPS: request via SSL\n", ff);
else
@@ -1774,6 +1776,8 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
write(sock, tmp->ptr, tmp->length);
if(w3m_reqlog){
FILE *ff = fopen(w3m_reqlog, "a");
if (ff == NULL)
return uf;
fwrite(tmp->ptr, sizeof(char), tmp->length, ff);
fclose(ff);
}