summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-06-09 10:02:52 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-06-09 10:11:02 +0200
commit600ec501bafc691d37078a0ed5b4ca8bf32340f1 (patch)
treecc3fe4993deeb021ed0bb36b6b9b286cc18ade1e
parent10ea757b0d10826034c4602b8d1caf717129124f (diff)
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
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySet.cxx12
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySet.hxx2
2 files changed, 7 insertions, 7 deletions
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;