Skip to content

Commit

Permalink
Merge pull request #57 from bitonic/utf8ncmp-safe
Browse files Browse the repository at this point in the history
exit in `utf8ncmp` if over limit before reading
  • Loading branch information
sheredom committed Jan 20, 2019
2 parents 3f44e9e + 634096a commit 2a7c5bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utf8.h
Expand Up @@ -559,7 +559,7 @@ int utf8ncmp(const void *src1, const void *src2, size_t n) {
const unsigned char *s1 = (const unsigned char *)src1;
const unsigned char *s2 = (const unsigned char *)src2;

while ((('\0' != *s1) || ('\0' != *s2)) && (0 != n--)) {
while ((0 != n--) && (('\0' != *s1) || ('\0' != *s2))) {
if (*s1 < *s2) {
return -1;
} else if (*s1 > *s2) {
Expand Down

0 comments on commit 2a7c5bf

Please sign in to comment.