summaryrefslogtreecommitdiff
path: root/sax/source
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-06-29 17:14:58 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-06-30 00:24:16 +0200
commitb2aafa91233189a623032894e9259b0f850efe2a (patch)
tree8e0d4f25effb87052310c7cf9bff2697048b5e5a /sax/source
parentbe1a2fb3ad0e5a7a364886a83c9bdc895717cdfd (diff)
sax: fix overflow in sax::Converter::convertMeasure()
The problem is that -2^31 is negative after negation in 2's complement. This causes ODF validation error now in CppunitTest_sd_export_tests testFdo84043: Error: attribute "svg:x" has a bad value: ... svg:x="--2147483.-6-4-7cm" The validation error only happens in 32-bit builds; 64-bit builds show a different value svg:x="2139324.72cm", so there must be another problem somewhere else that isn't fixed here. Change-Id: If2040cb6ae914c69b7cc651d3ab2d5d232fc71fb Reviewed-on: https://gerrit.libreoffice.org/56718 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sax/source')
-rw-r--r--sax/source/tools/converter.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 250c756e64e6..fd450affb5f4 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -280,10 +280,11 @@ void Converter::convertMeasure( OUStringBuffer& rBuffer,
return;
}
+ sal_Int64 nValue(nMeasure); // extend to 64-bit first to avoid overflow
// the sign is processed separately
- if( nMeasure < 0 )
+ if (nValue < 0)
{
- nMeasure = -nMeasure;
+ nValue = -nValue;
rBuffer.append( '-' );
}
@@ -401,7 +402,6 @@ void Converter::convertMeasure( OUStringBuffer& rBuffer,
break;
}
- sal_Int64 nValue = nMeasure;
OSL_ENSURE(nValue <= SAL_MAX_INT64 / nMul, "convertMeasure: overflow");
nValue *= nMul;
nValue /= nDiv;