summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/wbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/wbuf.c')
-rw-r--r--lib/libc/stdio/wbuf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c
index 3f697e2..5bc3c4d 100644
--- a/lib/libc/stdio/wbuf.c
+++ b/lib/libc/stdio/wbuf.c
@@ -36,6 +36,7 @@ static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <stdio.h>
#include "local.h"
@@ -59,8 +60,10 @@ __swbuf(int c, FILE *fp)
* calls might wrap _w from negative to positive.
*/
fp->_w = fp->_lbfsize;
- if (prepwrite(fp) != 0)
+ if (prepwrite(fp) != 0) {
+ errno = EBADF;
return (EOF);
+ }
c = (unsigned char)c;
ORIENT(fp, -1);
OpenPOWER on IntegriCloud