Skip to content

Commit

Permalink
Check MB_CUR_MAX in UTF-8 functions
Browse files Browse the repository at this point in the history
Borrowed from OpenBSD.
  • Loading branch information
mptre authored and calleluks committed Oct 4, 2016
1 parent 7c30d66 commit 860b931
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,11 @@ delete_between(char *string, size_t length, size_t start, size_t end)
int
isu8cont(unsigned char c)
{
return (c & (0x80 | 0x40)) == 0x80;
return MB_CUR_MAX > 1 && (c & (0x80 | 0x40)) == 0x80;
}

int
isu8start(unsigned char c)
{
return (c & (0x80 | 0x40)) == (0x80 | 0x40);
return MB_CUR_MAX > 1 && (c & (0x80 | 0x40)) == (0x80 | 0x40);
}

0 comments on commit 860b931

Please sign in to comment.