oox/source/helper/attributelist.cxx       |    3 +++
 sc/source/filter/oox/pivotcachebuffer.cxx |   11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit e6593922d026ab7adbdb88084637b2e018af88c9
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Dec 20 12:58:12 2022 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Dec 20 15:56:45 2022 +0000

    crashtesting: assert on import of forum-mso-en4-253564.xlsx
    
    source document contains a timestamp formatted as:
    
    2011-010-31T00: 00:00Z
         ^^^
    Change-Id: I604ffa69189280faf9d7f55dae472cf9fe1b6763
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144601
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/oox/source/helper/attributelist.cxx 
b/oox/source/helper/attributelist.cxx
index 49ff32a967f5..037483cefb5a 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -263,7 +263,10 @@ std::optional< util::DateTime > 
AttributeList::getDateTime( sal_Int32 nAttrToken
         (aValue[ 4 ] == '-') && (aValue[ 7 ] == '-') && (aValue[ 10 ] == 'T') 
&&
         (aValue[ 13 ] == ':') && (aValue[ 16 ] == ':');
     if (!bValid)
+    {
+        SAL_WARN("oox", "bad date string: " << aValue);
         return std::optional< util::DateTime >();
+    }
     aDateTime.Year    = static_cast< sal_uInt16 >( 
o3tl::toInt32(aValue.substr( 0, 4 )) );
     aDateTime.Month   = static_cast< sal_uInt16 >( 
o3tl::toInt32(aValue.substr( 5, 2 )) );
     aDateTime.Day     = static_cast< sal_uInt16 >( 
o3tl::toInt32(aValue.substr( 8, 2 )) );
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx 
b/sc/source/filter/oox/pivotcachebuffer.cxx
index 76d5af6fd65b..4896f3123e92 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -245,7 +245,16 @@ OUString PivotCacheItem::getFormattedName(const 
ScDPSaveDimension& rSaveDim, ScD
         case XML_n: return pObj->GetFormattedString(rSaveDim.GetName(), 
maValue.get<double>());
         case XML_i: return pObj->GetFormattedString(rSaveDim.GetName(), 
static_cast<double>(maValue.get< sal_Int32 >()));
         case XML_b: return pObj->GetFormattedString(rSaveDim.GetName(), 
static_cast<double>(maValue.get< bool >()));
-        case XML_d: return pObj->GetFormattedString(rSaveDim.GetName(), 
maValue.get< css::util::DateTime >() - rNullDate);
+        case XML_d:
+        {
+            css::util::DateTime aDateTime(maValue.get< css::util::DateTime 
>());
+            if (aDateTime.Year == 0)
+            {
+                SAL_WARN("sc", "PivotCacheField::getFormattedName - invalid 
date");
+                return OUString();
+            }
+            return pObj->GetFormattedString(rSaveDim.GetName(), aDateTime - 
rNullDate);
+        }
         case XML_e: return maValue.get< OUString >();
     }
     OSL_FAIL( "PivotCacheItem::getFormattedName - invalid data type" );

Reply via email to