Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Unified Diff: source/common/rbbidata.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/common/rbbidata.h ('k') | source/common/rbbiscan.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/common/rbbidata.cpp
diff --git a/source/common/rbbidata.cpp b/source/common/rbbidata.cpp
index 09d47964e61274bee6904925dfbd5766ebee6e0b..271553a89c19b3449e3bb7d5d50c32ca5d669cbc 100644
--- a/source/common/rbbidata.cpp
+++ b/source/common/rbbidata.cpp
@@ -1,6 +1,6 @@
/*
***************************************************************************
-* Copyright (C) 1999-2010 International Business Machines Corporation *
+* Copyright (C) 1999-2014 International Business Machines Corporation *
* and others. All rights reserved. *
***************************************************************************
*/
@@ -46,20 +46,39 @@ U_NAMESPACE_BEGIN
//
//-----------------------------------------------------------------------------
RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, UErrorCode &status) {
+ init0();
init(data, status);
}
RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, enum EDontAdopt, UErrorCode &status) {
+ init0();
init(data, status);
fDontFreeData = TRUE;
}
RBBIDataWrapper::RBBIDataWrapper(UDataMemory* udm, UErrorCode &status) {
- const RBBIDataHeader *d = (const RBBIDataHeader *)
- // ((char *)&(udm->pHeader->info) + udm->pHeader->info.size);
- // taking into consideration the padding added in by udata_write
- ((char *)(udm->pHeader) + udm->pHeader->dataHeader.headerSize);
- init(d, status);
+ init0();
+ if (U_FAILURE(status)) {
+ return;
+ }
+ const DataHeader *dh = udm->pHeader;
+ int32_t headerSize = dh->dataHeader.headerSize;
+ if ( !(headerSize >= 20 &&
+ dh->info.isBigEndian == U_IS_BIG_ENDIAN &&
+ dh->info.charsetFamily == U_CHARSET_FAMILY &&
+ dh->info.dataFormat[0] == 0x42 && // dataFormat="Brk "
+ dh->info.dataFormat[1] == 0x72 &&
+ dh->info.dataFormat[2] == 0x6b &&
+ dh->info.dataFormat[3] == 0x20)
+ // Note: info.fFormatVersion is duplicated in the RBBIDataHeader, and is
+ // validated when checking that.
+ ) {
+ status = U_INVALID_FORMAT_ERROR;
+ return;
+ }
+ const char *dataAsBytes = reinterpret_cast<const char *>(dh);
+ const RBBIDataHeader *rbbidh = reinterpret_cast<const RBBIDataHeader *>(dataAsBytes + headerSize);
+ init(rbbidh, status);
fUDataMem = udm;
}
@@ -69,6 +88,19 @@ RBBIDataWrapper::RBBIDataWrapper(UDataMemory* udm, UErrorCode &status) {
// constructors.
//
//-----------------------------------------------------------------------------
+void RBBIDataWrapper::init0() {
+ fHeader = NULL;
+ fForwardTable = NULL;
+ fReverseTable = NULL;
+ fSafeFwdTable = NULL;
+ fSafeRevTable = NULL;
+ fRuleSource = NULL;
+ fRuleStatusTable = NULL;
+ fUDataMem = NULL;
+ fRefCount = 0;
+ fDontFreeData = TRUE;
+}
+
void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) {
if (U_FAILURE(status)) {
return;
@@ -84,10 +116,6 @@ void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) {
// an int32_t field, rather than an array of 4 bytes.
fDontFreeData = FALSE;
- fUDataMem = NULL;
- fReverseTable = NULL;
- fSafeFwdTable = NULL;
- fSafeRevTable = NULL;
if (data->fFTableLen != 0) {
fForwardTable = (RBBIStateTable *)((char *)data + fHeader->fFTable);
}
« no previous file with comments | « source/common/rbbidata.h ('k') | source/common/rbbiscan.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698