include/svx/numfmtsh.hxx | 2 ++ svx/source/items/numfmtsh.cxx | 11 +++++++---- sw/source/ui/fldui/DateFormFieldDialog.cxx | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-)
New commits: commit f1d7cedf2cd656bb19c68d0797b536c56f0e2683 Author: Caolán McNamara <[email protected]> AuthorDate: Sun Aug 3 21:33:53 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Mon Aug 4 12:36:22 2025 +0200 cid#1660815 Dereference null return value Change-Id: I47c9e02859f69df1f1849113fcb52a217eb26193 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188888 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/source/ui/fldui/DateFormFieldDialog.cxx b/sw/source/ui/fldui/DateFormFieldDialog.cxx index d7d3fd9ea7c9..f3516e8c7306 100644 --- a/sw/source/ui/fldui/DateFormFieldDialog.cxx +++ b/sw/source/ui/fldui/DateFormFieldDialog.cxx @@ -42,13 +42,15 @@ DateFormFieldDialog::~DateFormFieldDialog() {} void DateFormFieldDialog::Apply() { - if (m_pDateField == nullptr) + if (!m_pDateField) return; // Try to find out the current date value and replace the content // with the right formatted date string sw::mark::Fieldmark::parameter_map_t* pParameters = m_pDateField->GetParameters(); const SvNumberformat* pFormat = m_pNumberFormatter->GetEntry(m_xFormatLB->GetFormat()); + if (!pFormat) + return; // Get date value first std::pair<bool, double> aResult = m_pDateField->GetCurrentDate(); commit bb4f58f1a397a7aae51ce2759900d2507cbd1773 Author: Caolán McNamara <[email protected]> AuthorDate: Sun Aug 3 21:30:57 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Mon Aug 4 12:36:12 2025 +0200 cid#1660799 silence Dereference null return value Change-Id: I7392878e4e17bc70d11c13122bd657ad5a531dd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188887 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins diff --git a/include/svx/numfmtsh.hxx b/include/svx/numfmtsh.hxx index db593eb8b77d..e11f0cdf71d9 100644 --- a/include/svx/numfmtsh.hxx +++ b/include/svx/numfmtsh.hxx @@ -227,6 +227,8 @@ private: const Color*& rpColor ); SVX_DLLPRIVATE static void PosToCategory_Impl(sal_uInt16 nPos, SvNumFormatType& rCategory); SVX_DLLPRIVATE static void CategoryToPos_Impl(SvNumFormatType nCategory, sal_uInt16& rPos); + + SVX_DLLPRIVATE bool IsNotNatNum12(short nEntry) const; }; #endif diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index 28dbbb8268cb..88ffff63ff35 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -1328,6 +1328,12 @@ bool SvxNumberFormatShell::GetUserDefined4Entry(short nEntry) return false; } +bool SvxNumberFormatShell::IsNotNatNum12(short nEntry) const +{ + const SvNumberformat* pNumEntry = pFormatter->GetEntry(aCurEntryList[nEntry]); + return !pNumEntry || pNumEntry->GetFormatstring().indexOf("NatNum12") < 0; +} + /* * Function: Returns the format string for a given entry. * Input: Number of the entry @@ -1338,10 +1344,7 @@ OUString SvxNumberFormatShell::GetFormat4Entry(short nEntry) if (nEntry < 0) return OUString(); - if (!aCurrencyFormatList.empty() - && (!pFormatter->GetEntry(aCurEntryList[nEntry]) - || pFormatter->GetEntry(aCurEntryList[nEntry])->GetFormatstring().indexOf("NatNum12") - < 0)) + if (!aCurrencyFormatList.empty() && IsNotNatNum12(nEntry)) { if (aCurrencyFormatList.size() > o3tl::make_unsigned(nEntry)) return aCurrencyFormatList[nEntry];
