Loading...
--- Libc/Libc-763.13/stdio/FreeBSD/wbuf.c
+++ Libc/Libc-1669.60.4/stdio/FreeBSD/wbuf.c
@@ -37,6 +37,7 @@
__FBSDID("$FreeBSD: src/lib/libc/stdio/wbuf.c,v 1.12 2007/01/09 00:28:08 imp Exp $");
#include <stdio.h>
+#include <errno.h>
#include "local.h"
/*
@@ -47,9 +48,7 @@
* Non-MT-safe
*/
int
-__swbuf(c, fp)
- int c;
- FILE *fp;
+__swbuf(int c, FILE *fp)
{
int n;
@@ -61,8 +60,10 @@
* 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);