diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-05-24 15:26:06 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-05-24 16:50:03 +0200 |
commit | 5060c5015882b7109c54598c4ea858949beafc43 (patch) | |
tree | c8c153d73f6c6ebbe2dae768c1da72d28312efd4 /sdext | |
parent | a86818c15a6b4773ddd012db37d55b5204163c24 (diff) |
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has
just been proven to be non-negative here
Change-Id: I20600d61a5d59d739bc1bee838c0038e4611aec2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/pdfimport/tree/imagecontainer.cxx | 3 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterAccessibility.cxx | 4 | ||||
-rw-r--r-- | sdext/source/presenter/PresenterTextView.cxx | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/sdext/source/pdfimport/tree/imagecontainer.cxx b/sdext/source/pdfimport/tree/imagecontainer.cxx index 9754e9134a50..a7154164d771 100644 --- a/sdext/source/pdfimport/tree/imagecontainer.cxx +++ b/sdext/source/pdfimport/tree/imagecontainer.cxx @@ -24,6 +24,7 @@ #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <com/sun/star/beans/PropertyValue.hpp> @@ -111,7 +112,7 @@ ImageId ImageContainer::addImage( const uno::Sequence<beans::PropertyValue>& xBi void ImageContainer::writeBase64EncodedStream( ImageId nId, EmitContext& rContext ) { - OSL_ASSERT( nId >= 0 && nId < ImageId( m_aImages.size()) ); + OSL_ASSERT( nId >= 0 && o3tl::make_unsigned(nId) < m_aImages.size() ); const uno::Sequence<beans::PropertyValue>& rEntry( m_aImages[nId] ); diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx index 10d73b88d898..e3f49ed1dddf 100644 --- a/sdext/source/presenter/PresenterAccessibility.cxx +++ b/sdext/source/presenter/PresenterAccessibility.cxx @@ -792,7 +792,7 @@ Reference<XAccessible> SAL_CALL { ThrowIfDisposed(); - if (nIndex<0 || nIndex>=sal_Int32(maChildren.size())) + if (nIndex<0 || o3tl::make_unsigned(nIndex)>=maChildren.size()) throw lang::IndexOutOfBoundsException("invalid child index", static_cast<uno::XWeak*>(this)); return maChildren[nIndex]; @@ -1229,7 +1229,7 @@ AccessibleStateSet::AccessibleStateSet (const sal_Int32 nStateSet) sal_uInt32 AccessibleStateSet::GetStateMask (const sal_Int16 nState) { - if (nState<0 || nState>=sal_Int16(sizeof(sal_uInt32)*8)) + if (nState<0 || o3tl::make_unsigned(nState)>=sizeof(sal_uInt32)*8) { throw RuntimeException("AccessibleStateSet::GetStateMask: invalid state"); } diff --git a/sdext/source/presenter/PresenterTextView.cxx b/sdext/source/presenter/PresenterTextView.cxx index f77ef93bc6d8..d83229b88e2a 100644 --- a/sdext/source/presenter/PresenterTextView.cxx +++ b/sdext/source/presenter/PresenterTextView.cxx @@ -419,7 +419,7 @@ SharedPresenterTextParagraph PresenterTextView::GetParagraph ( { if (nParagraphIndex < 0) return SharedPresenterTextParagraph(); - else if (nParagraphIndex>=sal_Int32(maParagraphs.size())) + else if (o3tl::make_unsigned(nParagraphIndex)>=maParagraphs.size()) return SharedPresenterTextParagraph(); else return maParagraphs[nParagraphIndex]; |