svl/source/numbers/zforscan.cxx |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit db00c13579a94dd256a01e76ef230cde342f30db
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Fri Jul 1 00:03:10 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Fri Jul 1 02:01:34 2022 +0200

    ChangeNullDate: assert valid date after normalization if it wasn't before
    
    ... and abort if not. Also take over only valid values.
    
    This might pop up more crashtest import failures that would need
    fixes similar to commit 7ca3eca66888a1fa1b7bd59d79bb8f4c96bd7460.
    
    Change-Id: I217204378374a1a598b5a3ff3c9c6728f112af70
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136688
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index a5f25637678a..10ff6a591b35 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -519,14 +519,18 @@ void ImpSvNumberformatScan::SetDependentKeywords()
 
 void ImpSvNumberformatScan::ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, 
sal_Int16 nYear)
 {
-    maNullDate = Date(nDay, nMonth, nYear);
-    if (!maNullDate.IsValidDate())
+    Date aDate(nDay, nMonth, nYear);
+    if (!aDate.IsValidDate())
     {
-        maNullDate.Normalize();
+        aDate.Normalize();
         SAL_WARN("svl.numbers","ImpSvNumberformatScan::ChangeNullDate - not 
valid"
                 " d: " << nDay << " m: " << nMonth << " y: " << nYear << " 
normalized to"
-                " d: " << maNullDate.GetDay() << " m: " << 
maNullDate.GetMonth() << " y: " << maNullDate.GetYear());
+                " d: " << aDate.GetDay() << " m: " << aDate.GetMonth() << " y: 
" << aDate.GetYear());
+        // Slap the caller if really bad, like year 0.
+        assert(aDate.IsValidDate());
     }
+    if (aDate.IsValidDate())
+        maNullDate = aDate;
 }
 
 void ImpSvNumberformatScan::ChangeStandardPrec(sal_uInt16 nPrec)

Reply via email to