From 7a49f77b1ec67910214936229ca5305a2fa6e9c8 Mon Sep 17 00:00:00 2001 From: Jia Zhouyang Date: Sun, 4 Mar 2018 20:57:08 +0800 Subject: Add error handling code for fopen Check the return code of fopen, and return when it fails. --- url.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'url.c') diff --git a/url.c b/url.c index d759383..348f501 100644 --- a/url.c +++ b/url.c @@ -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); } -- cgit v1.2.3