aboutsummaryrefslogtreecommitdiffstats
path: root/news.c
diff options
context:
space:
mode:
authorDavid Crosby <dave@dafyddcrosby.com>2015-07-26 02:36:09 +0000
committerTatsuya Kinoshita <tats@debian.org>2015-08-11 12:59:27 +0000
commitb1bf058d2a8b06aca24538ab58596117f3dece48 (patch)
tree9b5803f2fb7802aae4d2aae50e5fe925611919f1 /news.c
parentRemove unused value (diff)
downloadw3m-b1bf058d2a8b06aca24538ab58596117f3dece48.tar.gz
w3m-b1bf058d2a8b06aca24538ab58596117f3dece48.zip
Check dup call for errors
Diffstat (limited to '')
-rw-r--r--news.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/news.c b/news.c
index 8a1f0e8..c0494b7 100644
--- a/news.c
+++ b/news.c
@@ -76,13 +76,15 @@ news_close(News * news)
static int
news_open(News * news)
{
- int sock, status;
+ int sock, status, fd;
sock = openSocket(news->host, "nntp", news->port);
if (sock < 0)
goto open_err;
news->rf = newInputStream(sock);
- news->wf = fdopen(dup(sock), "wb");
+ if ((fd = dup(sock)) < 0)
+ goto open_err;
+ news->wf = fdopen(fd, "wb");
if (!news->rf || !news->wf)
goto open_err;
IStype(news->rf) |= IST_UNCLOSE;