diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c index 67d22bfca7b..7340ce15667 100644 --- a/usr.bin/locate/locate/fastfind.c +++ b/usr.bin/locate/locate/fastfind.c @@ -48,6 +48,7 @@ statistic (fp, path_fcodes) register u_char *p, *s; register int c; int count; + int error = 0; u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; for (c = 0, p = bigram1, s = bigram2; c < NBG; c++) { @@ -69,6 +70,7 @@ statistic (fp, path_fcodes) if (count < 0 || count > MAXPATHLEN) { /* stop on error and display the statstics anyway */ warnx("corrupted database: %s", path_fcodes); + error = 1; break; } @@ -104,6 +106,9 @@ statistic (fp, path_fcodes) (void)printf("Integers: %ld, ", zwerg); (void)printf("8-Bit characters: %ld\n", umlaut); + /* non zero exit on corrupt database */ + if (error) + exit(error); } #endif /* _LOCATE_STATISTIC_ */