editeng/source/rtf/rtfitem.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
New commits: commit c93d70db199cc7f89490cf9f34aa43ea67892c52 Author: Jonathan Clark <[email protected]> AuthorDate: Tue Sep 16 14:21:34 2025 -0600 Commit: Jonathan Clark <[email protected]> CommitDate: Wed Sep 17 18:25:25 2025 +0200 tdf#168424 editeng: Fix unsafe s/uint implicit cast in RTF parser The editeng RTF parser was round-tripping signed integers through a sal_uInt16 via implicit casts when populating SvxLRSpaceItem. This worked because such an implicit cast may convert signed numbers into their unsigned two's complement representation, and vice-versa. Unfortunately, a recent change to SvxLRSpaceItem replaced the final implicit uint-to-sint cast with an implicit uint-to-double one, which does not have the same properties. Change-Id: I80b1a36c47323309b33a8ddaee652c238a7530f3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191052 Tested-by: Jenkins Reviewed-by: Jonathan Clark <[email protected]> diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index ab08b92682f8..1e547dc37c4b 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -318,12 +318,12 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) if (const TypedWhichId<SvxLRSpaceItem> wid = aPardMap[SID_ATTR_LRSPACE]) { SvxLRSpaceItem aLR(pSet->Get(wid)); - sal_uInt16 nSz = 0; + sal_Int16 nSz = 0; if( -1 != nTokenValue ) { if( IsCalcValue() ) CalcValue(); - nSz = sal_uInt16(nTokenValue); + nSz = sal_Int16(nTokenValue); } aLR.SetTextFirstLineOffset(SvxIndentValue::twips(nSz)); pSet->Put( aLR ); @@ -335,12 +335,12 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) if (const TypedWhichId<SvxLRSpaceItem> wid = aPardMap[SID_ATTR_LRSPACE]) { SvxLRSpaceItem aLR(pSet->Get(wid)); - sal_uInt16 nSz = 0; + sal_Int16 nSz = 0; if( 0 < nTokenValue ) { if( IsCalcValue() ) CalcValue(); - nSz = sal_uInt16(nTokenValue); + nSz = sal_Int16(nTokenValue); } aLR.SetTextLeft(SvxIndentValue::twips(nSz)); pSet->Put( aLR ); @@ -352,12 +352,12 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) if (const TypedWhichId<SvxLRSpaceItem> wid = aPardMap[SID_ATTR_LRSPACE]) { SvxLRSpaceItem aLR(pSet->Get(wid)); - sal_uInt16 nSz = 0; + sal_Int16 nSz = 0; if( 0 < nTokenValue ) { if( IsCalcValue() ) CalcValue(); - nSz = sal_uInt16(nTokenValue); + nSz = sal_Int16(nTokenValue); } aLR.SetRight(SvxIndentValue::twips(nSz)); pSet->Put( aLR );
