From: Koji Arai Date: Sun, 8 May 2016 00:30:41 +0000 (+0900) Subject: Abort when getc() is failed. X-Git-Url: http://git.osdn.net/view?p=lha%2Flha.git;a=commitdiff_plain;h=0f89645cf5fc0d2dcd7d79828147d4adb00ec210 Abort when getc() is failed. --- diff --git a/src/bitio.c b/src/bitio.c index 91001ea..ac4e61b 100644 --- a/src/bitio.c +++ b/src/bitio.c @@ -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--; - subbitbuf = (unsigned char) getc(infile); + int c = getc(infile); + if (c == EOF) { + fatal_error("cannot read stream"); + } + subbitbuf = (unsigned char)c; } else subbitbuf = 0;