8077520: Morph tables into improved form

Reviewed-by: prr, srl, mschoene
This commit is contained in:
Vadim Pakhnushev 2015-04-16 11:27:23 +03:00
parent 71f032b764
commit 490c3dee9c
2 changed files with 16 additions and 4 deletions

View File

@ -41,7 +41,7 @@ U_NAMESPACE_BEGIN
LEReferenceTo<FeatureTable> FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const
{
LEReferenceToArrayOf<FeatureRecord>
featureRecordArrayRef(base, success, featureRecordArray, featureIndex);
featureRecordArrayRef(base, success, featureRecordArray, featureIndex+1);
if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) {
return LEReferenceTo<FeatureTable>();

View File

@ -239,6 +239,18 @@ public:
return fLength;
}
/**
* Throw an error if size*count overflows
*/
size_t verifyLength(size_t offset, size_t size, le_uint32 count, LEErrorCode &success) {
if(count!=0 && size>LE_UINT32_MAX/count) {
LE_DEBUG_TR3("verifyLength failed size=%u, count=%u", size, count);
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
return 0;
}
return verifyLength(offset, size*count, success);
}
/**
* Change parent link to another
*/
@ -424,7 +436,7 @@ public:
if(fCount == LE_UNBOUNDED_ARRAY) { // not a known length
fCount = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
}
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*fCount, success);
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize(), fCount, success);
}
if(LE_FAILURE(success)) {
fCount=0;
@ -439,7 +451,7 @@ _TRTRACE("INFO: new RTAO")
if(fCount == LE_UNBOUNDED_ARRAY) { // not a known length
fCount = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
}
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*fCount, success);
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize(), fCount, success);
}
if(LE_FAILURE(success)) clear();
}
@ -450,7 +462,7 @@ _TRTRACE("INFO: new RTAO")
if(fCount == LE_UNBOUNDED_ARRAY) { // not a known length
fCount = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
}
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*fCount, success);
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize(), fCount, success);
}
if(LE_FAILURE(success)) clear();
}