aboutsummaryrefslogtreecommitdiffstats
path: root/chkfont.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-05-08 14:52:05 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2012-05-08 14:52:05 +0100
commit3a941f4ae2213f26118f5cfde03ca793b31ca838 (patch)
tree8ad0b9793d5ae8cf716bb288828fea12efb1d1c1 /chkfont.c
parente8ed9bd2e7597f7aefdfc7004a308f0e291c3ca7 (diff)
downloadfiglet-3a941f4ae2213f26118f5cfde03ca793b31ca838.tar.gz
Imported Upstream version 2.2.3upstream/2.2.3
Diffstat (limited to '')
-rw-r--r--chkfont.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/chkfont.c b/chkfont.c
index 8272207..92fefad 100644
--- a/chkfont.c
+++ b/chkfont.c
@@ -1,6 +1,9 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
#define DATE "20 Feb 1996"
#define VERSION "2.2"
@@ -68,10 +71,9 @@ char *ptr;
ptr=(char *)malloc(size);
if (ptr==NULL) {
fprintf(stderr,"%s: Out of memory\n",myname);
+ exit(1);
}
-else {
- return(ptr);
- }
+return(ptr);
}
int badsuffix(path,suffix)
@@ -103,15 +105,22 @@ fprintf(stderr,"Usage: %s fontfile ...\n",myname);
exit(1);
}
-
void readchar()
{
int i,expected_width,k,len,newlen,diff,l;
char endmark,expected_endmark;
int leadblanks,minleadblanks,trailblanks,mintrailblanks;
+char *ret;
+expected_width = expected_endmark = 0; /* prevent compiler warning */
for (i=0;i<charheight;i++) {
- fgets(fileline,maxlen+1000,fontfile);
+ ret = fgets(fileline,maxlen+1000,fontfile);
+ if (ret == NULL) {
+ printf("%s: ERROR (fatal)- Unexpected read error after line %d.\n",
+ fontfilename,currline);
+ ec++;
+ weregone(1); if (gone) return;
+ }
if (feof(fontfile)) {
printf("%s: ERROR (fatal)- Unexpected end of file after line %d.\n",
fontfilename,currline);
@@ -235,7 +244,12 @@ if (fontfile!=stdin) {
weregone(0); if (gone) return;
}
}
-fscanf(fontfile,"%4s",magicnum);
+numsread=fscanf(fontfile,"%4s",magicnum);
+if (numsread == EOF) {
+ printf("%s: ERROR- can't read magic number.\n",fontfilename);
+ ec++;
+ weregone(0); if (gone) return;
+ }
if (strcmp(magicnum,FONTFILEMAGICNUMBER)) {
printf("%s: ERROR- Incorrect magic number.\n",fontfilename);
ec++;
@@ -457,5 +471,5 @@ for (arg=1;arg<argc;arg++) {
checkit();
if (fileline!=NULL) free(fileline);
}
-exit(0);
+return 0;
}