[Libreoffice-commits] core.git: sw/source

Stephan Bergmann sbergman at redhat.com
Thu Sep 1 11:56:32 UTC 2016


 sw/source/filter/html/css1atr.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit bf3c6237bb110d3eb84970e44593a7880e2e8536
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Sep 1 13:50:06 2016 +0200

    pTemplate can probably be null here
    
    Observed with "make clean && make CppunitTest_sw_filters_test" (which misses a
    dependency, a bug to be fixed next, so happens to not set up m_pTemplate in
    SwHTMLWriter::WriteStream, so dereferences a null pTemplate here.  Don't know
    whether there's also legitimate scenarios that can lead to a null pTemplate
    here, but at least the code in SwHTMLWriter::WriteStream setting up m_pTemplate
    takes into account that it can be set up as null, and the code in the called
    SwHTMLWriter::GetTemplateFormat takes into account that the passed in pTemplate
    (which used to be the same object as the outer pTemplate/pDoc, before breaking
    IDocumentStylePoolAccess out of SwDoc, see below) can be null.
    
    Regression introduced with 535971f3a166da6c0e44a6b7211c7f8c298f388f "Refactored
    IDocumentStylePoolAccess out of SwDoc."
    
    Change-Id: Iabb4ae2ca018ce3a19756d62b9002b245cb409cd

diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 44f0bd5..609b344 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -1561,16 +1561,16 @@ static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
     switch( nDeep )
     {
     case CSS1_FMT_ISTAG:
-        pRefFormat = SwHTMLWriter::GetTemplateFormat( nRefPoolId, &pTemplate->getIDocumentStylePoolAccess() );
+        pRefFormat = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pTemplate == nullptr ? nullptr : &pTemplate->getIDocumentStylePoolAccess() );
         break;
     case CSS1_FMT_CMPREF:
         pRefFormat = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pDoc );
-        pRefFormatScript = SwHTMLWriter::GetTemplateFormat( nRefPoolId, &pTemplate->getIDocumentStylePoolAccess() );
+        pRefFormatScript = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pTemplate == nullptr ? nullptr : &pTemplate->getIDocumentStylePoolAccess() );
         bClearSame = false;
         break;
     default:
         pRefFormat = SwHTMLWriter::GetParentFormat( rFormat, nDeep );
-        pRefFormatScript = SwHTMLWriter::GetTemplateFormat( nRefPoolId, &pTemplate->getIDocumentStylePoolAccess() );
+        pRefFormatScript = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pTemplate == nullptr ? nullptr : &pTemplate->getIDocumentStylePoolAccess() );
         bSetDefaults = false;
         break;
     }


More information about the Libreoffice-commits mailing list