Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Avoid a potential infinite loop when losing sync at EOF.

  • Loading branch information...
commit cfbe364b1442141775becd6259a4a9634891882e 1 parent 68bce0e
@threedaymonk authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  count-codepoints.c
View
3  count-codepoints.c
@@ -13,6 +13,7 @@ int32_t read_utf8_codepoint(FILE* fp){
int32_t result, byte, i, j, k;
resync:
+ if (0 != feof(fp)) goto fail;
byte = (int32_t)fgetc(fp);
if (byte < 0x80) return byte;
@@ -28,6 +29,8 @@ int32_t read_utf8_codepoint(FILE* fp){
return result;
}
}
+
+fail:
return -1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.