summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-01-09 19:43:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-01-09 20:34:01 +0100
commit6417668b3e12d9659ac5dc4a2f60aa8ad3bca675 (patch)
treef5e33e736054c0027d48fc40a207401de6d1e715 /filter
parent6efffbbfce9c27439f54970f7a569b069ce46eba (diff)
Introduce o3tl::make_unsigned to cast from signed to unsigned type
...without having to spell out a specific type to cast to (and also making it more obvious what the intend of such a cast is) Change-Id: Id9c68b856a4ee52e5a40d15dc9d83e95d1c231cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86502 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/icgm/class1.cxx6
-rw-r--r--filter/source/graphicfilter/icgm/class4.cxx9
2 files changed, 11 insertions, 4 deletions
diff --git a/filter/source/graphicfilter/icgm/class1.cxx b/filter/source/graphicfilter/icgm/class1.cxx
index 2661931d7df2..30e28dd820cc 100644
--- a/filter/source/graphicfilter/icgm/class1.cxx
+++ b/filter/source/graphicfilter/icgm/class1.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/safeint.hxx>
+
#include "bundles.hxx"
#include "cgm.hxx"
#include "elements.hxx"
@@ -169,7 +173,7 @@ void CGM::ImplDoClass1()
{
sal_uInt32 nSize = ImplGetUI(1);
- if (static_cast<sal_uInt32>(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
+ if (o3tl::make_unsigned(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
throw css::uno::Exception("attempt to read past end of input", nullptr);
pElement->aFontList.InsertName( mpSource + mnParaSize, nSize );
diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx
index 4760215ebe18..2e3f3c439cdb 100644
--- a/filter/source/graphicfilter/icgm/class4.cxx
+++ b/filter/source/graphicfilter/icgm/class4.cxx
@@ -23,6 +23,9 @@
#include "chart.hxx"
#include "elements.hxx"
#include "outact.hxx"
+
+#include <o3tl/safeint.hxx>
+
#include <math.h>
#include <memory>
@@ -186,7 +189,7 @@ void CGM::ImplDoClass4()
sal_uInt32 nType = ImplGetUI16();
sal_uInt32 nSize = ImplGetUI( 1 );
- if (static_cast<sal_uInt32>(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
+ if (o3tl::make_unsigned(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
throw css::uno::Exception("attempt to read past end of input", nullptr);
OUString aStr(reinterpret_cast<char*>(mpSource) + mnParaSize, nSize, RTL_TEXTENCODING_ASCII_US);
@@ -223,7 +226,7 @@ void CGM::ImplDoClass4()
sal_uInt32 nType = ImplGetUI16();
sal_uInt32 nSize = ImplGetUI(1);
- if (static_cast<sal_uInt32>(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
+ if (o3tl::make_unsigned(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
throw css::uno::Exception("attempt to read past end of input", nullptr);
OUString aStr(reinterpret_cast<char*>(mpSource) + mnParaSize, nSize, RTL_TEXTENCODING_ASCII_US);
@@ -240,7 +243,7 @@ void CGM::ImplDoClass4()
(void)ImplGetUI16(); // nType
sal_uInt32 nSize = ImplGetUI( 1 );
- if (static_cast<sal_uInt32>(mpEndValidSource - (mpSource + mnParaSize)) <= nSize)
+ if (o3tl::make_unsigned(mpEndValidSource - (mpSource + mnParaSize)) <= nSize)
throw css::uno::Exception("attempt to read past end of input", nullptr);
mpSource[ mnParaSize + nSize ] = 0;