summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-03-04 12:27:39 +0000
committerCaolán McNamara <caolanm@redhat.com>2010-03-04 12:27:39 +0000
commit5020b64b0ec461c18c545b868148841a0bb4904b (patch)
treebe009f649c95018f5ccf24f5e5aa534aedfd251d
parent892d87e002a1430ac679c738378a7b205599392b (diff)
downloadhyphen-5020b64b0ec461c18c545b868148841a0bb4904b.tar.gz
check return value of fgets
-rw-r--r--hyphen.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/hyphen.c b/hyphen.c
index 8a111d1..26fbefd 100644
--- a/hyphen.c
+++ b/hyphen.c
@@ -289,10 +289,13 @@ for (k = 0; k == 0 || (k == 1 && nextlevel); k++) {
/* read in character set info */
if (k == 0) {
for (i=0;i<MAX_NAME;i++) dict[k]->cset[i]= 0;
- fgets(dict[k]->cset, sizeof(dict[k]->cset),f);
- for (i=0;i<MAX_NAME;i++)
- if ((dict[k]->cset[i] == '\r') || (dict[k]->cset[i] == '\n'))
- dict[k]->cset[i] = 0;
+ if (fgets(dict[k]->cset, sizeof(dict[k]->cset),f) != NULL) {
+ for (i=0;i<MAX_NAME;i++)
+ if ((dict[k]->cset[i] == '\r') || (dict[k]->cset[i] == '\n'))
+ dict[k]->cset[i] = 0;
+ } else {
+ dict[k]->cset[0] = 0;
+ }
dict[k]->utf8 = (strcmp(dict[k]->cset, "UTF-8") == 0);
} else {
strcpy(dict[k]->cset, dict[0]->cset);