- fixed SF# 581: Out-of-bound array access in Unicode::properties() function.

This commit is contained in:
Guenter Obiltschnig 2012-11-10 11:44:44 +01:00
parent c0f725b888
commit 12b0255f58
2 changed files with 8 additions and 2 deletions

View File

@ -1,7 +1,7 @@
//
// Unicode.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Unicode.h#1 $
// $Id: //poco/1.4/Foundation/include/Poco/Unicode.h#2 $
//
// Library: Foundation
// Package: Text
@ -188,6 +188,11 @@ public:
UCP_VAI
};
enum
{
UCP_MAX_CODEPOINT = 0x10FFFF
};
struct CharacterProperties
/// This structure holds the character properties
/// of an Unicode character.

View File

@ -1,7 +1,7 @@
//
// Unicode.cpp
//
// $Id: //poco/1.4/Foundation/src/Unicode.cpp#1 $
// $Id: //poco/1.4/Foundation/src/Unicode.cpp#2 $
//
// Library: Foundation
// Package: Text
@ -49,6 +49,7 @@ namespace Poco {
void Unicode::properties(int ch, CharacterProperties& props)
{
if (ch > UCP_MAX_CODEPOINT) ch = 0;
const ucd_record* ucd = GET_UCD(ch);
props.category = static_cast<CharacterCategory>(_pcre_ucp_gentype[ucd->chartype]);
props.type = static_cast<CharacterType>(ucd->chartype);