diff options
| author | Caolán McNamara <caolanm@redhat.com> | 2010-03-04 12:27:39 +0000 |
|---|---|---|
| committer | Caolán McNamara <caolanm@redhat.com> | 2010-03-04 12:27:39 +0000 |
| commit | 5020b64b0ec461c18c545b868148841a0bb4904b (patch) | |
| tree | be009f649c95018f5ccf24f5e5aa534aedfd251d | |
| parent | 892d87e002a1430ac679c738378a7b205599392b (diff) | |
| download | hyphen-5020b64b0ec461c18c545b868148841a0bb4904b.tar.gz | |
check return value of fgets
| -rw-r--r-- | hyphen.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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); |
