svl/source/numbers/zforlist.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit d807d6a65f439da88623e45b1dabe7d9ef36cd3c
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed Jan 16 18:19:54 2019 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Wed Jan 16 20:36:13 2019 +0100

    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 <er...@redhat.com>
    Tested-by: Jenkins

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(')');
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to