[Libreoffice-commits] core.git: sw/source
Stephan Bergmann
sbergman at redhat.com
Wed Jan 24 07:25:03 UTC 2018
sw/source/core/fields/cellfml.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit ab6d3b3794f64b6dde8e9309f4fd99051aecbda3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Jan 23 17:52:41 2018 +0100
Remove presumably dead < USHRT_MAX checks
The original code of 84a3db80b4fd66c6854b3135b5f69b61fd828e62 "initial import"
read
+ long nBoxOffset = lcl_GetLongBoxNum( sGetName ) + nSttBox;
+ long nLineOffset = lcl_GetLongBoxNum( sGetName ) + nSttLine;
+
+ if( nBoxOffset < 0 || nBoxOffset >= USHRT_MAX ||
+ nLineOffset < 0 || nLineOffset >= USHRT_MAX )
+ return 0;
+
+ if( nLineOffset >= long(pLines->Count()) )
+ return 0;
+
+ pLine = (*pLines)[ USHORT(nLineOffset) ];
+
+ // dann suche die Box
+ pBoxes = &pLine->GetTabBoxes();
+ if( nBoxOffset >= long(pBoxes->Count()) )
+ return 0;
+ pBox = (*pBoxes)[ USHORT(nBoxOffset) ];
casting nBox/LineOffset to USHORT, while the current code looks like it should
work fine for larger values.
Change-Id: I47bdf3963be6e84568a589711ce688b66f325db8
Reviewed-on: https://gerrit.libreoffice.org/48451
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index ea2a4eaef9ca..f32b330b3413 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -782,8 +782,8 @@ static const SwTableBox* lcl_RelToBox( const SwTable& rTable,
const sal_Int32 nBoxOffset = lcl_GetLongBoxNum( sGetName ) + nSttBox;
const sal_Int32 nLineOffset = lcl_GetLongBoxNum( sGetName ) + nSttLine;
- if( nBoxOffset < 0 || nBoxOffset >= USHRT_MAX ||
- nLineOffset < 0 || nLineOffset >= USHRT_MAX )
+ if( nBoxOffset < 0 ||
+ nLineOffset < 0 )
return nullptr;
if( static_cast<size_t>(nLineOffset) >= pLines->size() )
More information about the Libreoffice-commits
mailing list