From 94c65497d9f25acb6ebd3c9d8cca1d069988bbe3 Mon Sep 17 00:00:00 2001 From: ntrifunovic Date: Sun, 27 Aug 2006 02:31:23 +0000 Subject: [PATCH] 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 --- source/utf8.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/utf8.h b/source/utf8.h index b7e8479..62ac58e 100644 --- a/source/utf8.h +++ b/source/utf8.h @@ -126,10 +126,14 @@ namespace internal typedef typename std::iterator_traits::difference_type octet_difference_type; octet_difference_type sequence_length; if (cp < 0x80) { - if (code_point) - *code_point = cp; - ++it; - return OK; + if (end - it > 0) { + if (code_point) + *code_point = cp; + ++it; + return OK; + } + else + return NOT_ENOUGH_ROOM; } else if ((cp >> 5) == 0x6) sequence_length = 2;