summaryrefslogtreecommitdiff
path: root/src/spellfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spellfile.c')
-rw-r--r--src/spellfile.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/spellfile.c b/src/spellfile.c
index d5ec3fead..12dedd6c5 100644
--- a/src/spellfile.c
+++ b/src/spellfile.c
@@ -816,11 +816,15 @@ read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
// read the length bytes, MSB first
for (i = 0; i < cnt_bytes; ++i)
- cnt = (cnt << 8) + (unsigned)getc(fd);
- if (cnt < 0)
{
- *cntp = SP_TRUNCERROR;
- return NULL;
+ int c = getc(fd);
+
+ if (c == EOF)
+ {
+ *cntp = SP_TRUNCERROR;
+ return NULL;
+ }
+ cnt = (cnt << 8) + (unsigned)c;
}
*cntp = cnt;
if (cnt == 0)