diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-06-09 10:02:52 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-06-10 11:52:08 +0200 |
commit | 9db9c8e04958a30a954e7176ab3556a8cb397fca (patch) | |
tree | 6394913a78f08388198a4f17a32ac496e4cfd27a /writerfilter | |
parent | a6c0b1a2b7c8d29bf3561fff472a4b5684e4967b (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
(cherry picked from commit 600ec501bafc691d37078a0ed5b4ca8bf32340f1)
Reviewed-on: https://gerrit.libreoffice.org/38632
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/ooxml/OOXMLPropertySet.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLPropertySet.hxx | 2 |
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; |