diff options
author | Eike Rathke <erack@redhat.com> | 2022-06-30 23:49:03 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-07-01 00:48:15 +0200 |
commit | d031accf712cde8f664828ec4547bf6a4661860f (patch) | |
tree | 28ab268136865804b5aa6b83349b28f387c5617c | |
parent | 8480e15f854cfc0a6b99a6b28f794465d0fb8253 (diff) |
Check sax::Converter::parseDateTime() success return value
Change-Id: Ia843a1437a8c97e2dafc3f22d43a3dc61873269b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136686
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
-rw-r--r-- | sc/source/filter/oox/revisionfragment.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLCalculationSettingsContext.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/core/DocumentSettingsContext.cxx | 6 |
3 files changed, 17 insertions, 9 deletions
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx index 4a0fa785e6df..405e45f8e26b 100644 --- a/sc/source/filter/oox/revisionfragment.cxx +++ b/sc/source/filter/oox/revisionfragment.cxx @@ -286,11 +286,15 @@ void RevisionHeadersFragment::importHeader( const AttributeList& rAttribs ) if (!aDateTimeStr.isEmpty()) { util::DateTime aDateTime; - sax::Converter::parseDateTime(aDateTime, aDateTimeStr); - Date aDate(aDateTime); - tools::Time aTime(aDateTime); - aMetadata.maDateTime.SetDate(aDate.GetDate()); - aMetadata.maDateTime.SetTime(aTime.GetTime()); + if (sax::Converter::parseDateTime(aDateTime, aDateTimeStr)) + { + Date aDate(aDateTime); + tools::Time aTime(aDateTime); + aMetadata.maDateTime.SetDate(aDate.GetDate()); + aMetadata.maDateTime.SetTime(aTime.GetTime()); + } + else + SAL_WARN("sc.filter", "RevisionHeadersFragment: broken DateTime '" << aDateTimeStr << "'"); } aMetadata.maUserName = rAttribs.getString(XML_userName, OUString()); diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx index 9365a791c901..fbe54c96d0f8 100644 --- a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx +++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx @@ -44,8 +44,10 @@ SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport& if ( aIter.getToken() == XML_ELEMENT(TABLE, XML_DATE_VALUE) ) { util::DateTime aNullDate; - ::sax::Converter::parseDateTime(aNullDate, aIter.toView()); - m_aNullDate <<= aNullDate; + if (::sax::Converter::parseDateTime(aNullDate, aIter.toView())) + m_aNullDate <<= aNullDate; + else + SAL_WARN("xmloff", "SchXMLCalculationSettingsContext: broken DateTime '" << aIter.toView() << "'"); } else XMLOFF_WARN_UNKNOWN("xmloff", aIter); diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx index b21010b07c81..9052a8dbaa81 100644 --- a/xmloff/source/core/DocumentSettingsContext.cxx +++ b/xmloff/source/core/DocumentSettingsContext.cxx @@ -462,8 +462,10 @@ void XMLConfigItemContext::endFastElement(sal_Int32 ) else if (IsXMLToken(msType, XML_DATETIME)) { util::DateTime aDateTime; - ::sax::Converter::parseDateTime(aDateTime, sValue); - mrAny <<= aDateTime; + if (::sax::Converter::parseDateTime(aDateTime, sValue)) + mrAny <<= aDateTime; + else + SAL_WARN("xmloff.core", "XMLConfigItemContext: broken DateTime '" << sValue << "'"); } else if (IsXMLToken(msType, XML_BASE64BINARY)) { |