From 33e3bc8c62bf71eab27c4567d0894025419ff2f5 Mon Sep 17 00:00:00 2001 From: shivers Date: Tue, 8 Apr 1997 20:07:30 +0000 Subject: [PATCH] Was not properly testing for error in fdport_write_substring's call to fwrite(). --- scsh/fdports1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scsh/fdports1.c b/scsh/fdports1.c index 78562ac..6dc00e5 100644 --- a/scsh/fdports1.c +++ b/scsh/fdports1.c @@ -394,8 +394,9 @@ int read_fdport_substring(scheme_value buf, int start, int end, scheme_value dat int write_fdport_substring(scheme_value buf, int start, int end, scheme_value data) { FILE *f = fstar_cache[EXTRACT_FIXNUM(*PortData_Fd(data))]; - int retval = fwrite(StrByte(buf,start), 1, end-start, f); - return ferror(f) ? -1 : retval; /* -1: error, 0: eof */ + int nbytes = end - start; + int retval = fwrite(StrByte(buf,start), 1, nbytes, f); + return (retval < nbytes) ? -1 : retval; /* -1: error, otw numwritten */ } /* 1st return value says why we terminated the read: