tdf#144072 prevent use of a deleted pointer
BegDragObj_createInvisibleObjectAtPosition() may clear the handle list and that will delete the SdrHdl instances owned by this section view so set _pHdl to null if it has been deleted during the call. Change-Id: I89606958f8a76a2c35685d1aff6b0159739a464a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155119 Tested-by: Jenkins Reviewed-by: Patrick Luby <plubius@neooffice.org>
This commit is contained in:
@@ -1043,7 +1043,21 @@ void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionVi
|
||||
"createInvisible X:" << aRect.Left() << " Y:"
|
||||
<< aRect.Top() << " on View #" << nViewCount);
|
||||
|
||||
// tdf#144072 prevent use of a deleted pointer
|
||||
// BegDragObj_createInvisibleObjectAtPosition() may clear
|
||||
// the handle list and that will delete the SdrHdl instances
|
||||
// owned by this section view so set _pHdl to null if it has
|
||||
// been deleted during the call.
|
||||
bool bHdlInList = false;
|
||||
const SdrHdlList& rHdlList = rView.GetHdlList();
|
||||
if (_pHdl && rHdlList.GetHdlNum(_pHdl) < rHdlList.GetHdlCount())
|
||||
bHdlInList = true;
|
||||
BegDragObj_createInvisibleObjectAtPosition(aRect, rView);
|
||||
if (bHdlInList && rHdlList.GetHdlNum(_pHdl) >= rHdlList.GetHdlCount())
|
||||
{
|
||||
SAL_WARN("reportdesign", "SdrHdl pointer parameter has been deleted");
|
||||
_pHdl = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2282,7 +2282,6 @@ size_t SdrHdlList::GetHdlNum(const SdrHdl* pHdl) const
|
||||
return SAL_MAX_SIZE;
|
||||
auto it = std::find_if( maList.begin(), maList.end(),
|
||||
[&](const std::unique_ptr<SdrHdl> & p) { return p.get() == pHdl; });
|
||||
assert(it != maList.end());
|
||||
if( it == maList.end() )
|
||||
return SAL_MAX_SIZE;
|
||||
return it - maList.begin();
|
||||
|
||||
Reference in New Issue
Block a user