tdf#154142 null-deref in SfxUndoManager::SetMaxUndoActionCount

Change-Id: I09cfbccb5f2ffa009a3e40157c9373b7e10864dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157764
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 0eea4d0..028fdc7 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -135,7 +135,7 @@ ScFormatShell::ScFormatShell(ScViewData& rData) :
    SetPool( &pTabViewShell->GetPool() );
    SfxUndoManager* pMgr = rViewData.GetSfxDocShell()->GetUndoManager();
    SetUndoManager( pMgr );
    if ( !rViewData.GetDocument().IsUndoEnabled() )
    if (pMgr && !rViewData.GetDocument().IsUndoEnabled())
    {
        pMgr->SetMaxUndoActionCount( 0 );
    }