Include <stdlib.h>.
authorJim Meyering <jim@meyering.net>
Sun, 5 Dec 2004 18:52:33 +0000 (18:52 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 5 Dec 2004 18:52:33 +0000 (18:52 +0000)
(__fpending): Abort if PENDING_OUTPUT_N_BYTES is negative.
This ensures that if there is an error in the definition of the
PENDING_OUTPUT_N_BYTES expression, we'll find about it right away;
this value is used only in the rare event that close_stdout's
fclose fails with EBADF.

lib/__fpending.c

index 007302c..c2405cd 100644 (file)
@@ -21,6 +21,8 @@
 # include <config.h>
 #endif
 
+#include <stdlib.h>
+
 #include "__fpending.h"
 
 /* Return the number of pending (aka buffered, unflushed)
@@ -28,5 +30,8 @@
 size_t
 __fpending (FILE *fp)
 {
-  return PENDING_OUTPUT_N_BYTES;
+  ptrdiff_t n = PENDING_OUTPUT_N_BYTES;
+  if (n < 0)
+    abort ();
+  return n;
 }