summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2019-01-16 18:19:54 +0100
committerEike Rathke <erack@redhat.com>2019-01-16 20:36:13 +0100
commitd807d6a65f439da88623e45b1dabe7d9ef36cd3c (patch)
tree0cb5108c7d433f7d230a994c60f720308ba50cba /svl
parentc9d19b70c93b02e5c666414097e835039c598731 (diff)
Related: tdf#122509 prevent access of not existing base format
Call to pFormat->HasPositiveBracketPlaceholder() with nullptr as obtained for the not existing nIndex was the immediate cause of the crash. Also obtain the type from the format if found instead of the separate GetType() call that again would need to find the format first. This clarifies that the other places accessing pFormat don't need additional checks because eType isn't UNDEFINED there. Change-Id: I5d78ad73eeb4c3820c45d6a91b0e729ed22951a4 Reviewed-on: https://gerrit.libreoffice.org/66476 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforlist.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 747996c8d564..aa5e58eebd83 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2862,7 +2862,10 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
{
eLnge = IniLnge;
}
- SvNumFormatType eType = GetType(nIndex);
+
+ const SvNumberformat* pFormat = GetFormatEntry( nIndex );
+ const SvNumFormatType eType = (pFormat ? pFormat->GetMaskedType() : SvNumFormatType::UNDEFINED);
+
ImpGenerateCL(eLnge); // create new standard formats if necessary
utl::DigitGroupingIterator aGrouping( xLocaleData->getDigitGrouping());
@@ -2870,8 +2873,6 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
const sal_Int32 nDigitsInFirstGroup = ( bThousand && (eType == SvNumFormatType::SCIENTIFIC) ) ? 3 : aGrouping.get();
const OUString& rThSep = GetNumThousandSep();
- SvNumberformat* pFormat = GetFormatEntry( nIndex );
-
OUStringBuffer sString;
using comphelper::string::padToLength;
@@ -3019,7 +3020,7 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex,
{
OUStringBuffer sTmpStr(sString);
- if ( pFormat->HasPositiveBracketPlaceholder() )
+ if (pFormat && pFormat->HasPositiveBracketPlaceholder())
{
sTmpStr.append('_');
sTmpStr.append(')');