Added a boundary check to the optimization branch of next_validate

git-svn-id: http://svn.code.sf.net/p/utfcpp/code@52 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
ntrifunovic 2006-08-27 02:31:23 +00:00
parent 4e848f2c69
commit 94c65497d9

View file

@ -126,11 +126,15 @@ namespace internal
typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type; typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
octet_difference_type sequence_length; octet_difference_type sequence_length;
if (cp < 0x80) { if (cp < 0x80) {
if (end - it > 0) {
if (code_point) if (code_point)
*code_point = cp; *code_point = cp;
++it; ++it;
return OK; return OK;
} }
else
return NOT_ENOUGH_ROOM;
}
else if ((cp >> 5) == 0x6) else if ((cp >> 5) == 0x6)
sequence_length = 2; sequence_length = 2;
else if ((cp >> 4) == 0xe) else if ((cp >> 4) == 0xe)