diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-11-04 18:07:13 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-04 21:07:03 +0100 |
commit | c400c36018e8d89bbf8e551258a480c8f6571efe (patch) | |
tree | ab174914aedf936c679560b6e652140526812cbc /sfx2 | |
parent | 6e4336bcd26911fdb20051b58050d24c141ce372 (diff) |
sw: fix heap-use-after-free in SwDBManager::MergeMailFiles()
This went wrong in commit b1d13c48b57633c156e7d76fe81fc5828d1e3e20 (sw:
fix merge mail multiple files, 2022-10-18).
There were 3 problems here:
1) SwDBManager::MergeMailFiles() called SetDBManager() on an SwDoc, but
that SwDoc has been already deleted by
SfxObjectShellLock::operator=() that owns it. Fix the problem by
switching our reference of that SwDoc to rtl::Reference<SwDoc> and then
clearing that reference before the owning SwDocShell would be deleted.
2) Now that the SwDoc is either alive or is properly a nullptr, need to
check if our SwDoc is nullptr before calling SetDBManager() on it.
3) Now that the doc shell is a SfxObjectShellRef and the doc is a
rtl::Reference<SwDoc>, need to make sure that the doc is declared
after the doc shell, since the SwDoc dtor will access its doc shell, but
not the other way around.
Change-Id: Ie10bac422a6d39b4401c90ecd67637b511e5b705
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142282
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2')
0 files changed, 0 insertions, 0 deletions