diff options
author | Eike Rathke <erack@redhat.com> | 2022-07-01 00:03:10 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-07-01 02:01:34 +0200 |
commit | db00c13579a94dd256a01e76ef230cde342f30db (patch) | |
tree | d60917dbf2c856952610f4228d85ea382febf1a4 /svl | |
parent | 216b33b8eaf144f438f87b7a35e35d04baf943bd (diff) |
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 <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zforscan.cxx | 12 |
1 files changed, 8 insertions, 4 deletions
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) |