fixed some segfault's

This commit is contained in:
akool 1999-06-18 13:28:11 +00:00
parent fab3fa6dc9
commit d4b4d53fe2
4 changed files with 5 additions and 23 deletions

View File

@ -4,7 +4,7 @@
# (C) 1999 l.toetsch <lt@toetsch.at> # (C) 1999 l.toetsch <lt@toetsch.at>
# #
SHELL = /bin/sh SHELL = /bin/sh
CFLAGS = -Wall -O2 CFLAGS = -Wall -g
INCLUDES = INCLUDES =
LDFLAGS = @DBMLIB@ LDFLAGS = @DBMLIB@
DBEXT = @DBEXT@ DBEXT = @DBEXT@

Binary file not shown.

View File

@ -76,11 +76,8 @@ static int numlen;
static void read_codefile(char *cf) { static void read_codefile(char *cf) {
FILE *fp; FILE *fp;
int l, llen = 0; int l, llen = 0;
#if 0 char *p;
char *line, *p; auto char line[BUFSIZ];
#else
char line[BUFSIZ], *p;
#endif
nc = 0; nc = 0;
if (verbose) if (verbose)
@ -95,11 +92,7 @@ static void read_codefile(char *cf) {
printf("%d\r", nc); printf("%d\r", nc);
fflush(stdout); fflush(stdout);
} }
#if 0
l = getline(&line, &llen, fp);
#else
fgets(line, BUFSIZ, fp); fgets(line, BUFSIZ, fp);
#endif
if (!isdigit(*line)) if (!isdigit(*line))
continue; continue;
line[strlen(line)-1] = '\0'; line[strlen(line)-1] = '\0';
@ -133,14 +126,12 @@ static void read_codefile(char *cf) {
codes[nc].num=-1; codes[nc].num=-1;
codes[nc].code=strdup(""); codes[nc].code=strdup("");
free(cf); free(cf);
#if 0
free(line);
#endif
} }
static void read_rzfile(char *rf) { static void read_rzfile(char *rf) {
int i; int i;
char *line, *p, *op; char line[BUFSIZ], *p, *op;
size_t llen, l; size_t llen, l;
FILE *fp; FILE *fp;
int from,to,z; int from,to,z;
@ -149,10 +140,6 @@ static void read_rzfile(char *rf) {
fprintf(stderr, "Coudn't read '%s'\n", rf); fprintf(stderr, "Coudn't read '%s'\n", rf);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if ((line = malloc(40)) == 0) {
fprintf(stderr, "Out of mem\n");
exit(EXIT_FAILURE);
}
llen=40; llen=40;
n=0; n=0;
zones = 0; zones = 0;
@ -169,12 +156,8 @@ static void read_rzfile(char *rf) {
printf("%d\r", n); printf("%d\r", n);
fflush(stdout); fflush(stdout);
} }
#if 0
l = getline(&line, &llen, fp);
#else
fgets(line, BUFSIZ, fp); fgets(line, BUFSIZ, fp);
l = strlen(line); l = strlen(line);
#endif
if (!l || l == -1 || !*line) if (!l || l == -1 || !*line)
break; break;
if (l>40) if (l>40)
@ -208,7 +191,6 @@ static void read_rzfile(char *rf) {
numbers[to]++; numbers[to]++;
n++; n++;
} }
free(line);
free(rf); free(rf);
} }

Binary file not shown.