Blob Blame History Raw
From bcc74f619bf87ab97ffc48ab33e031d357952a70 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Sun, 15 Dec 2019 10:03:56 +0100
Subject: [PATCH] Fix use of uninitialized SwFEShell::bTableCopied

...which had been introduced with 1e278d1d0cfb1d5375195aa764739f00633f21e8
"tdf#37156 Writer menu: Paste as Nested table", during
`make CppunitTest_sw_uiwriter CPPUNIT_TEST_NAME=SwUiWriterTest::testDde
VALGRIND=memcheck`:

> Conditional jump or move depends on uninitialised value(s)
>    at 0x1EBBFAF8: SwTransferable::PrepareForCopy(bool) (sw/source/uibase/dochdl/swdtflvr.cxx:896)
>    by 0x1EBC22BA: SwTransferable::Copy(bool) (sw/source/uibase/dochdl/swdtflvr.cxx:1144)
>    by 0x1ECB552D: SwBaseShell::ExecClpbrd(SfxRequest&) (sw/source/uibase/shells/basesh.cxx:277)
>    by 0x1C0D0BB0: SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) (include/sfx2/shell.hxx:197)
>    by 0x1C0D72EB: SfxDispatcher::Execute_(SfxShell&, SfxSlot const&, SfxRequest&, SfxCallMode) (sfx2/source/control/dispatch.cxx:764)
>    by 0x1C153977: SfxDispatchController_Impl::dispatch(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) (sfx2/source/control/unoctitm.cxx:760)
>    by 0x1C154916: SfxOfficeDispatch::dispatchWithNotification(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) (sfx2/source/control/unoctitm.cxx:245)
>    by 0x21FDE395: framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatch> const&, com::sun::star::util::URL const&, bool, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (framework/source/services/dispatchhelper.cxx:151)
>    by 0x21FDEC95: framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (framework/source/services/dispatchhelper.cxx:109)
>    by 0x19BF89C7: lcl_dispatchCommand(com::sun::star::uno::Reference<com::sun::star::lang::XComponent> const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (sw/qa/extras/uiwriter/uiwriter.cxx:4048)
>    by 0x19C1F3EC: SwUiWriterTest::testDde() (sw/qa/extras/uiwriter/uiwriter.cxx:4060)
>  Uninitialised value was created by a heap allocation
>    at 0x4839E86: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.15.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
>    by 0x1ED6DA43: SwView::SwView(SfxViewFrame*, SfxViewShell*) (sw/source/uibase/uiview/view.cxx:864)
>    by 0x1ED70065: SwView::CreateInstance(SfxViewFrame*, SfxViewShell*) (sw/source/uibase/uiview/view0.cxx:79)
>    by 0x1C347941: SfxBaseModel::createViewController(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (sfx2/source/doc/sfxbasemodel.cxx:4233)
>    by 0x1C458D81: (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (sfx2/source/view/frmload.cxx:587)
>    by 0x2401FAD0: framework::LoadEnv::impl_loadContent() (framework/source/loadenv/loadenv.cxx:1159)
>    by 0x24020735: framework::LoadEnv::start() (framework/source/loadenv/loadenv.cxx:392)
>    by 0x24020F89: framework::LoadEnv::startLoading(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, rtl::OUString const&, int, LoadEnvFeatures) (framework/source/loadenv/loadenv.cxx:297)
>    by 0x2402175B: framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (framework/source/loadenv/loadenv.cxx:166)
>    by 0x24058172: framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (framework/source/services/desktop.cxx:610)
>    by 0x1F5F7306: unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (unotest/source/cpp/macros_test.cxx:48)
>    by 0x19C646A7: SwModelTestBase::loadURL(rtl::OUString const&, char const*, char const*) (sw/qa/inc/swmodeltestbase.hxx:764)
>    by 0x19BD3792: SwUiWriterTest::createDoc(char const*) (sw/qa/extras/uiwriter/uiwriter.cxx:576)
>    by 0x19C1F352: SwUiWriterTest::testDde() (sw/qa/extras/uiwriter/uiwriter.cxx:4055)

(produced with a --enable-optimized build, so some inline frames are elided; see
also <https://ci.libreoffice.org//job/lo_ubsan/1480/> for the same issue
detected with UBSan).

Change-Id: I080d296006bad4726942fb95a1338ea46c12bed4
Reviewed-on: https://gerrit.libreoffice.org/85162
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
---
 sw/source/core/frmedt/fews.cxx | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 286b949e5f34..df6995a5174a 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -706,6 +706,7 @@ SwFEShell::SwFEShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption *pOp
     , m_bCheckForOLEInCaption(false)
     , m_aPasteListeners(GetPasteMutex())
     , m_eTableInsertMode(SwTable::SEARCH_NONE)
+    , bTableCopied(false)
 {
 }
 
@@ -714,6 +715,7 @@ SwFEShell::SwFEShell( SwEditShell& rShell, vcl::Window *pWindow )
     , m_bCheckForOLEInCaption(false)
     , m_aPasteListeners(GetPasteMutex())
     , m_eTableInsertMode(SwTable::SEARCH_NONE)
+    , bTableCopied(false)
 {
 }
 
-- 
2.28.0