patch 9.0.0384: Covertity still complains about using return value of getc()
Problem: Covertity still complains about using return value of getc().
Solution: Check for EOF.
diff --git a/src/spellfile.c b/src/spellfile.c
index b248b07..3c934fc 100644
--- a/src/spellfile.c
+++ b/src/spellfile.c
@@ -846,7 +846,7 @@
if (len > MAXREGIONS * 2)
return SP_FORMERROR;
for (i = 0; i < len; ++i)
- lp->sl_regions[i] = c = getc(fd); // <regionname>
+ lp->sl_regions[i] = (c = getc(fd)) == EOF ? 0 : c; // <regionname>
lp->sl_regions[len] = NUL;
return c == EOF ? SP_TRUNCERROR : 0;
}
@@ -927,7 +927,7 @@
buf[0] = '^'; // always match at one position only
p = buf + 1;
while (n-- > 0)
- *p++ = c = getc(fd); // <condstr>
+ *p++ = (c = getc(fd)) == EOF ? 0 : c; // <condstr>
if (c == EOF)
break;
*p = NUL;
@@ -1067,7 +1067,7 @@
// store the char we got while checking for end of sm_lead
*p++ = c;
for (++i; i < ccnt; ++i)
- *p++ = c = getc(fd); // <salfrom>
+ *p++ = (c = getc(fd)) == EOF ? 0 : c; // <salfrom>
*p++ = NUL;
// <saltolen> <salto>