sw/source/filter/ww8/ww8par.hxx | 5 +++-- sw/source/filter/ww8/ww8par5.cxx | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-)
New commits: commit ba9f87966feb61ba093f080d41e19b408a8355ff Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Jul 22 10:22:28 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jul 22 12:53:59 2024 +0200 add a static_assert for sizes of m_nFieldTagAlways and m_nFieldTagBad Change-Id: I4d847c74d8d069c76f874a19e6fbc99425757a44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170837 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index e8cb99c29fea..7855c712d6f0 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1307,8 +1307,9 @@ private: sal_uInt32 m_nIniFlags; // flags from writer.ini sal_uInt32 m_nIniFlags1; // ditto ( additional flags ) sal_uInt32 m_nFieldFlags; // ditto for fields - sal_uInt32 m_nFieldTagAlways[3]; // ditto for tagging of fields - sal_uInt32 m_nFieldTagBad[3]; // ditto for tagging of fields that can't be imported + static constexpr size_t FieldTagSize = 3; + sal_uInt32 m_nFieldTagAlways[FieldTagSize]; // ditto for tagging of fields + sal_uInt32 m_nFieldTagBad[FieldTagSize]; // ditto for tagging of fields that can't be imported bool m_bRegardHindiDigits; // import digits in CTL scripts as Hindi numbers bool m_bDrawCpOValid; diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 83b2ba301f53..774eb3740546 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -939,14 +939,19 @@ tools::Long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes) sal_uInt16 n = (aF.nId <= eMax) ? aF.nId : eMax; sal_uInt32 nI = n / 32U; // # of sal_uInt32 - sal_uInt32 nMask = 1 << ( n % 32 ); // Mask for bits - if (SAL_N_ELEMENTS(m_nFieldTagAlways) <= nI) + static_assert(FieldTagSize == SAL_N_ELEMENTS(m_nFieldTagAlways) && + FieldTagSize == SAL_N_ELEMENTS(m_nFieldTagBad), + "m_nFieldTagAlways and m_nFieldTagBad should have the same FieldTagSize num of elements"); + + if (nI >= FieldTagSize) { // if indexes larger than 95 are needed, then a new configuration // item has to be added, and nFieldTagAlways/nFieldTagBad expanded! return aF.nLen; } + sal_uInt32 nMask = 1 << ( n % 32 ); // Mask for bits + if( m_nFieldTagAlways[nI] & nMask ) // Flag: Tag it return Read_F_Tag( &aF ); // Result not as text