Kaydet (Commit) 85dfda49 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Adapt odd USHRT_MAX/4 limit in FIELD_PROP_PROP_SEQ handler

The code was added with 8ff71b59 "TextField and
FieldMaster 'Bibliography' completed", but, according to private communication
with Oliver, that specific values was chosen rather randomly.  Still, other
parts of the code assume m_SortKeyArr to be indexed by sal_uInt16, so use
SAL_MAX_UINT16 here to ensure the array is not getting to big causing overflow
in those other places.

Change-Id: I18ed75ed7c88b04e174a82194ae7d93a5f7f7c76
Reviewed-on: https://gerrit.libreoffice.org/48443Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 250ad931
......@@ -436,7 +436,10 @@ bool SwAuthorityFieldType::PutValue( const Any& rAny, sal_uInt16 nWhichId )
{
m_SortKeyArr.clear();
const PropertyValues* pValues = aSeq.getConstArray();
for(sal_Int32 i = 0; i < aSeq.getLength() && i < USHRT_MAX / 4; i++)
//TODO: Limiting to the first SAL_MAX_UINT16 elements of aSeq so that size of
// m_SortKeyArr remains in range of sal_uInt16, as GetSortKeyCount and GetSortKey
// still expect m_SortKeyArr to be indexed by sal_uInt16:
for(sal_Int32 i = 0; i < aSeq.getLength() && i < SAL_MAX_UINT16; i++)
{
const PropertyValue* pValue = pValues[i].getConstArray();
SwTOXSortKey aSortKey;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment