Loading...
stdio/FreeBSD/wbuf.c Libc-763.13 Libc-1506.40.4
--- Libc/Libc-763.13/stdio/FreeBSD/wbuf.c
+++ Libc/Libc-1506.40.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"
 
 /*
@@ -61,8 +62,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);