OSDN Git Service

Abort when getc() is failed.
authorKoji Arai <jca02266@gmail.com>
Sun, 8 May 2016 00:30:41 +0000 (09:30 +0900)
committerKoji Arai <jca02266@gmail.com>
Sun, 8 May 2016 00:31:03 +0000 (09:31 +0900)
src/bitio.c

index 91001ea..ac4e61b 100644 (file)
@@ -20,7 +20,11 @@ fillbuf(n)          /* Shift bitbuf n bits left, read n bits */
         bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount));
         if (compsize != 0) {
             compsize--;
         bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount));
         if (compsize != 0) {
             compsize--;
-            subbitbuf = (unsigned char) getc(infile);
+            int c = getc(infile);
+            if (c == EOF) {
+                fatal_error("cannot read stream");
+            }
+            subbitbuf = (unsigned char)c;
         }
         else
             subbitbuf = 0;
         }
         else
             subbitbuf = 0;