diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-11-20 09:46:23 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-11-20 15:14:35 +0100 |
commit | b6937a5c9d99dd1e7110d01f69923f45047259fe (patch) | |
tree | 012f7b381af6384cfef1127b7557276357904fac | |
parent | 7cd75ff1c9520e41d4803eda00538469393ab184 (diff) |
ofz#4306 Null-dereference READ
Change-Id: Iccbaed9ab6252ac8c61104ac0e6a9b8972913f6c
Reviewed-on: https://gerrit.libreoffice.org/44954
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/source/filter/excel/excel.cxx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx index 1954b02035be..536207f2e00a 100644 --- a/sc/source/filter/excel/excel.cxx +++ b/sc/source/filter/excel/excel.cxx @@ -38,6 +38,7 @@ #include <optuno.hxx> #include <xistream.hxx> +#include <docsh.hxx> #include <scerrors.hxx> #include <root.hxx> #include <imp_op.hxx> @@ -252,20 +253,31 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportXLS(SvStream& rStream) SfxMedium aMedium; css::uno::Reference<css::io::XInputStream> xStm(new utl::OInputStreamWrapper(rStream)); aMedium.GetItemSet()->Put(SfxUsrAnyItem(SID_INPUTSTREAM, css::uno::makeAny(xStm))); - ScDocument aDocument; - ScDocOptions aDocOpt = aDocument.GetDocOptions(); + + ScDocShellRef xDocShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | + SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | + SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + + xDocShell->DoInitNew(); + + ScDocument& rDoc = xDocShell->GetDocument(); + + ScDocOptions aDocOpt = rDoc.GetDocOptions(); aDocOpt.SetLookUpColRowNames(false); - aDocument.SetDocOptions(aDocOpt); - aDocument.MakeTable(0); - aDocument.EnableExecuteLink(false); + rDoc.SetDocOptions(aDocOpt); + rDoc.MakeTable(0); + rDoc.EnableExecuteLink(false); + rDoc.InitDrawLayer(xDocShell.get()); bool bRet(false); try { - bRet = ScFormatFilter::Get().ScImportExcel(aMedium, &aDocument, EIF_AUTO) == ERRCODE_NONE; + bRet = ScFormatFilter::Get().ScImportExcel(aMedium, &rDoc, EIF_AUTO) == ERRCODE_NONE; } catch (const css::ucb::ContentCreationException &) { } + xDocShell->DoClose(); + xDocShell.clear(); return bRet; } @@ -293,7 +305,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDIF(SvStream &rStream) aDocument.SetDocOptions(aDocOpt); aDocument.MakeTable(0); aDocument.EnableExecuteLink(false); - aDocument.InitDrawLayer(nullptr); return ScFormatFilter::Get().ScImportDif(rStream, &aDocument, ScAddress(0, 0, 0), RTL_TEXTENCODING_IBM_850) == ERRCODE_NONE; } |