提交 54b78e87 编写于 作者: V vadim

8077520: Morph tables into improved form

Reviewed-by: prr, srl, mschoene
上级 e3504637
......@@ -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>();
......
......@@ -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();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册