summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/ConvertUTF.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-05-09 18:36:44 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-05-09 18:36:44 +0000
commite54a1378ed622ce9a27fe77df89d32fbd17373ab (patch)
treea615fdf7f3c468cd3b206decf58bcf436458e469 /cpp/src/IceUtil/ConvertUTF.cpp
parentFixed compile error (diff)
downloadice-e54a1378ed622ce9a27fe77df89d32fbd17373ab.tar.bz2
ice-e54a1378ed622ce9a27fe77df89d32fbd17373ab.tar.xz
ice-e54a1378ed622ce9a27fe77df89d32fbd17373ab.zip
Fixed bug 965
Diffstat (limited to 'cpp/src/IceUtil/ConvertUTF.cpp')
-rwxr-xr-xcpp/src/IceUtil/ConvertUTF.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/cpp/src/IceUtil/ConvertUTF.cpp b/cpp/src/IceUtil/ConvertUTF.cpp
index 48b998ea50b..7bfd5f2990d 100755
--- a/cpp/src/IceUtil/ConvertUTF.cpp
+++ b/cpp/src/IceUtil/ConvertUTF.cpp
@@ -234,11 +234,25 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
* This is not used here; it's just exported.
*/
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
- int length = trailingBytesForUTF8[*source]+1;
- if (source+length > sourceEnd) {
- return false;
+ if(source == sourceEnd) {
+ return true;
+ }
+ while(true) {
+ int length = trailingBytesForUTF8[*source]+1;
+ // Is buffer big enough to contain character?
+ if (source+length > sourceEnd) {
+ return false;
+ }
+ // Is character legal UTF8?
+ if(!isLegalUTF8(source, length)) {
+ return false;
+ }
+ // Are we at end of buffer?
+ source += length;
+ if(source == sourceEnd) {
+ return true;
+ }
}
- return isLegalUTF8(source, length);
}
/* --------------------------------------------------------------------- */