From f4a55b6bcaaa2d0b7e6162ab735788c35efe096c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 4 Mar 2019 08:55:14 +0100 Subject: Avoid intermediate computation overflowing sal_uInt16 At least during CppunitTest_sw_uwriter, some m_nStrResId is read so that Clang's -fsanitize=implicit-signed-integer-truncation warned that an "implicit conversion from type 'int' of value 74752 (32-bit, signed) to type 'sal_uInt16' (aka 'unsigned short') changed the value to 9216 (16-bit, unsigned)". Change-Id: I39f12d931bb18eea909494c8d7c9c0348fb71f27 Reviewed-on: https://gerrit.libreoffice.org/68664 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sw/source/core/doc/tblafmt.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 6fe546fc32b5..fbf6270bdd8c 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -981,11 +981,9 @@ bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions ) { rStream.ReadUInt16( m_nStrResId ); // start from 3d because default is added via constructor - sal_uInt16 nId = RES_POOLTABLESTYLE_3D + m_nStrResId; - if( RES_POOLTABLESTYLE_3D <= nId && - nId < RES_POOLTABSTYLE_END ) + if( m_nStrResId < RES_POOLTABSTYLE_END - RES_POOLTABLESTYLE_3D ) { - m_aName = SwStyleNameMapper::GetUIName(nId, m_aName); + m_aName = SwStyleNameMapper::GetUIName(RES_POOLTABLESTYLE_3D + m_nStrResId, m_aName); } else m_nStrResId = USHRT_MAX; -- cgit