diff options
-rw-r--r-- | sax/qa/cppunit/test_converter.cxx | 1 | ||||
-rw-r--r-- | sax/source/tools/converter.cxx | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx index d58dd0bfb020..4cf2142c9a60 100644 --- a/sax/qa/cppunit/test_converter.cxx +++ b/sax/qa/cppunit/test_converter.cxx @@ -502,6 +502,7 @@ void ConverterTest::testMeasure() doTestMeasureToString("979.928cm", 555550, MeasureUnit::TWIP, MeasureUnit::CM); doTestMeasureToString("111.1pt", 2222, MeasureUnit::TWIP, MeasureUnit::POINT); doTestMeasureToString("385.7986in", 555550, MeasureUnit::TWIP, MeasureUnit::INCH); + doTestMeasureToString("-2147483.648cm", std::numeric_limits<sal_Int32>::min(), MeasureUnit::MM_100TH, MeasureUnit::CM); } void doTestStringToBool(bool bBool, char const*const pis) 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; |