[Libreoffice-commits] core.git: writerfilter/source
Stephan Bergmann
sbergman at redhat.com
Fri Jun 9 08:11:25 UTC 2017
writerfilter/source/ooxml/OOXMLPropertySet.cxx | 12 ++++++------
writerfilter/source/ooxml/OOXMLPropertySet.hxx | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
New commits:
commit 600ec501bafc691d37078a0ed5b4ca8bf32340f1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jun 9 10:02:52 2017 +0200
Avoid UBSan warning about negative double -> sal_uInt32 conversion
Since ea890b1d4bcd6dd59db9f52dce1609c020804e24 "tdf#108408: support unit
specifications for ST_HpsMeasure", the OOXMLUniversalMeasureValue ctor is
converting textual data to mnValue via intermediary double instead of sal_Int32,
so textual data representing negative values now triggers UBSan warnings (e.g.,
"writerfilter/source/ooxml/OOXMLPropertySet.cxx:630:43: runtime error: -70 is
outside the range of representable values of type 'unsigned int'" during
CppunitTest_chart2_export; it appears that, while HpsMeasure may be documented
to only cover positive values, TwipsMeasure may be negative).
But OOXMLUniversalMeasureValue::mnValue is apparently only used in
OOXMLUniversalMeasureValue::getInt, to return an int value, so just change its
type.
Change-Id: I44eabb78f09100c05cc9d1e79a739648f34ea743
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
index 3ef7a30b11ff..0b353dfb8039 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySet.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
@@ -599,35 +599,35 @@ OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(const char * pValue, sal_
pValue[nLen-2] == 'p' &&
pValue[nLen-1] == 't')
{
- mnValue = static_cast<sal_uInt32>(val * npPt);
+ mnValue = static_cast<int>(val * npPt);
}
else if (nLen > 2 &&
pValue[nLen - 2] == 'c' &&
pValue[nLen - 1] == 'm')
{
- mnValue = static_cast<sal_uInt32>(val * npPt * 72 / 2.54);
+ mnValue = static_cast<int>(val * npPt * 72 / 2.54);
}
else if (nLen > 2 &&
pValue[nLen - 2] == 'm' &&
pValue[nLen - 1] == 'm')
{
- mnValue = static_cast<sal_uInt32>(val * npPt * 72 / 25.4);
+ mnValue = static_cast<int>(val * npPt * 72 / 25.4);
}
else if (nLen > 2 &&
pValue[nLen - 2] == 'i' &&
pValue[nLen - 1] == 'n')
{
- mnValue = static_cast<sal_uInt32>(val * npPt * 72);
+ mnValue = static_cast<int>(val * npPt * 72);
}
else if (nLen > 2 &&
pValue[nLen - 2] == 'p' &&
( pValue[nLen - 1] == 'c' || pValue[nLen - 1] == 'i' ))
{
- mnValue = static_cast<sal_uInt32>(val * npPt * 12);
+ mnValue = static_cast<int>(val * npPt * 12);
}
else
{
- mnValue = static_cast<sal_uInt32>(val);
+ mnValue = static_cast<int>(val);
}
}
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.hxx b/writerfilter/source/ooxml/OOXMLPropertySet.hxx
index 73889a4abb9b..45aba15e2ccc 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySet.hxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySet.hxx
@@ -232,7 +232,7 @@ public:
class OOXMLUniversalMeasureValue : public OOXMLValue
{
private:
- sal_uInt32 mnValue;
+ int mnValue;
public:
OOXMLUniversalMeasureValue(const char * pValue, sal_uInt32 npPt);
virtual ~OOXMLUniversalMeasureValue() override;
More information about the Libreoffice-commits
mailing list