diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-05-09 18:36:44 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-05-09 18:36:44 +0000 |
commit | e54a1378ed622ce9a27fe77df89d32fbd17373ab (patch) | |
tree | a615fdf7f3c468cd3b206decf58bcf436458e469 /cppe/src/IceE/ConvertUTF.cpp | |
parent | Fixed compile error (diff) | |
download | ice-e54a1378ed622ce9a27fe77df89d32fbd17373ab.tar.bz2 ice-e54a1378ed622ce9a27fe77df89d32fbd17373ab.tar.xz ice-e54a1378ed622ce9a27fe77df89d32fbd17373ab.zip |
Fixed bug 965
Diffstat (limited to 'cppe/src/IceE/ConvertUTF.cpp')
-rwxr-xr-x | cppe/src/IceE/ConvertUTF.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/cppe/src/IceE/ConvertUTF.cpp b/cppe/src/IceE/ConvertUTF.cpp index 2282028f10e..1cc28b25488 100755 --- a/cppe/src/IceE/ConvertUTF.cpp +++ b/cppe/src/IceE/ConvertUTF.cpp @@ -233,11 +233,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);
}
/* --------------------------------------------------------------------- */
|