* chew.c (write_buffer): Check fwrite return value.
authorAlan Modra <amodra@gmail.com>
Mon, 15 Oct 2007 02:00:28 +0000 (02:00 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 15 Oct 2007 02:00:28 +0000 (02:00 +0000)
bfd/doc/ChangeLog
bfd/doc/chew.c

index b0fec4aa7c34c35f3d2bf6201b2978691c9786c0..51c71949b81d553a108bf67938fbdc2d6b95ce11 100644 (file)
@@ -1,3 +1,7 @@
+2007-10-15  Alan Modra  <amodra@bigpond.net.au>
+
+       * chew.c (write_buffer): Check fwrite return value.
+
 2007-09-14  Alan Modra  <amodra@bigpond.net.au>
 
        * Makefile.in: Regenerate.
index 344fa437030060e5709902af9114a4cff7a91bf3..5622ff2c668db155c106702667bc3f3d9ca207c7 100644 (file)
@@ -120,6 +120,7 @@ static void overwrite_string (string_type *, string_type *);
 static void catbuf (string_type *, char *, unsigned int);
 static void cattext (string_type *, char *);
 static void catstr (string_type *, string_type *);
+static void die (char *);
 #endif
 
 static void
@@ -162,7 +163,9 @@ write_buffer (buffer, f)
      string_type *buffer;
      FILE *f;
 {
-  fwrite (buffer->ptr, buffer->write_idx, 1, f);
+  if (buffer->write_idx != 0
+      && fwrite (buffer->ptr, buffer->write_idx, 1, f) != 1)
+    die ("cannot write output");
 }
 
 static void