From f0f19f87a38049e63097b2f285fc22065dde1ed3 Mon Sep 17 00:00:00 2001 From: dwarning Date: Tue, 30 Oct 2018 09:44:42 +0100 Subject: [PATCH] In case the file open failed we have no need to set the IO buffer size. And this should also not be done with a NULL pointer into setvbuf. --- src/frontend/runcoms.c | 3 +-- src/frontend/runcoms2.c | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index 16456d351..5b748a6cb 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -282,12 +282,11 @@ dosim( /*---------------------------------------------------------------------------*/ #else else if (!(rawfileFp = fopen(wl->wl_word, "w"))) { - rawfileFp = stdout; /* If fopen has failed, we have to proceed with stdout */ - setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); perror(wl->wl_word); ft_setflag = FALSE; return 1; } + setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); #endif /* __MINGW32__ */ rawfileBinary = !ascii; } else { diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index 3d42df443..1a0f63e6e 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -110,28 +110,27 @@ com_resume(wordlist *wl) /* ask if binary or ASCII, open file with w or wb hvogt 15.3.2000 */ else if (ascii) { if ((rawfileFp = fopen(last_used_rawfile, "a")) == NULL) { - setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); perror(last_used_rawfile); ft_setflag = FALSE; return; } + setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); } else if (!ascii) { if ((rawfileFp = fopen(last_used_rawfile, "ab")) == NULL) { - setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); perror(last_used_rawfile); ft_setflag = FALSE; return; } + setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); } /*---------------------------------------------------------------------------*/ #else else if (!(rawfileFp = fopen(last_used_rawfile, "a"))) { - rawfileFp = stdout; /* If fopen has failed, we have to proceed with stdout */ - setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); perror(last_used_rawfile); ft_setflag = FALSE; return; } + setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE); #endif rawfileBinary = !ascii; } else {