Skip to content

Commit

Permalink
Avoid a possible infinite loop using cpu_rec.c when there is a read e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
LRGH committed Apr 24, 2017
1 parent 2bf83f8 commit 21dfd6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cpu_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct stats count_ngrams(char *filename)
if (c>1)
r.m2[ buffer[1] + 256*buffer[0] ] += 1;
increment(r, buffer, c);
while (!feof(f)) {
while (c) {
buffer[0] = buffer[BUFSIZE-2];
buffer[1] = buffer[BUFSIZE-1];
c = fread(buffer+2, 1, BUFSIZE-2, f);
Expand Down

0 comments on commit 21dfd6b

Please sign in to comment.