summaryrefslogtreecommitdiff
path: root/sfx2/source/control
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-06-17 13:38:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-06-17 19:07:17 +0200
commit2176084192dc46a1ef5d6dd79effa5cd5d1dcca2 (patch)
tree782e5d67a2af49cd623228c003d417e64ceba653 /sfx2/source/control
parentbefa3f75fd7bf5ef35741d099ab18e94f10e4e1d (diff)
fix potential write-after-free in RecentDocsView
spotted while running a valgrind session Change-Id: I32c55ae2cc4b2d5abedca24c2f747aaa4183b3d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117382 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/control')
-rw-r--r--sfx2/source/control/recentdocsview.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx
index 137591a43991..0b01603d3914 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -130,6 +130,7 @@ RecentDocsView::RecentDocsView(std::unique_ptr<weld::ScrolledWindow> xWindow, st
, maWelcomeLine1(SfxResId(STR_WELCOME_LINE1))
, maWelcomeLine2(SfxResId(STR_WELCOME_LINE2))
, mpLoadRecentFile(nullptr)
+ , m_nExecuteHdlId(nullptr)
{
tools::Rectangle aScreen = Application::GetScreenPosSizePixel(Application::GetDisplayBuiltInScreen());
mnItemMaxSize = std::min(aScreen.GetWidth(),aScreen.GetHeight()) > 800 ? 256 : 192;
@@ -148,6 +149,8 @@ RecentDocsView::RecentDocsView(std::unique_ptr<weld::ScrolledWindow> xWindow, st
RecentDocsView::~RecentDocsView()
{
+ Application::RemoveUserEvent(m_nExecuteHdlId);
+ m_nExecuteHdlId = nullptr;
if (mpLoadRecentFile)
{
mpLoadRecentFile->pView = nullptr;
@@ -408,7 +411,7 @@ void RecentDocsView::PostLoadRecentUsedFile(LoadRecentFile* pLoadRecentFile)
{
assert(!mpLoadRecentFile);
mpLoadRecentFile = pLoadRecentFile;
- Application::PostUserEvent(LINK(nullptr, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile);
+ m_nExecuteHdlId = Application::PostUserEvent(LINK(this, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile);
}
void RecentDocsView::DispatchedLoadRecentUsedFile()
@@ -416,8 +419,9 @@ void RecentDocsView::DispatchedLoadRecentUsedFile()
mpLoadRecentFile = nullptr;
}
-IMPL_STATIC_LINK( RecentDocsView, ExecuteHdl_Impl, void*, p, void )
+IMPL_LINK( RecentDocsView, ExecuteHdl_Impl, void*, p, void )
{
+ m_nExecuteHdlId = nullptr;
LoadRecentFile* pLoadRecentFile = static_cast<LoadRecentFile*>(p);
try
{