Git commit 2994b9824edfec32b4b5cb17c4188394b226db24 by Frederik Gladhorn. Committed on 16/11/2016 at 16:24. Pushed by gladhorn into branch 'rempt/impex-refactoring'. Fix race condition in KisMergeWalker::startTripWithMask Summary: The parent pointer could become null right after the check. Making it safe is easy, just hold on to the pointer for the duration of the function. Reviewers: #krita Differential Revision: https://phabricator.kde.org/D3388 M +13 -16 libs/image/kis_merge_walker.cc http://commits.kde.org/krita/2994b9824edfec32b4b5cb17c4188394b226db24 diff --git a/libs/image/kis_merge_walker.cc b/libs/image/kis_merge_walker.cc index ef726ab..c0cff45 100644 --- a/libs/image/kis_merge_walker.cc +++ b/libs/image/kis_merge_walker.cc @@ -53,27 +53,24 @@ void KisMergeWalker::startTrip(KisProjectionLeafSP star= tLeaf) = void KisMergeWalker::startTripWithMask(KisProjectionLeafSP filthyMask) { - if (!filthyMask->parent()) { - /** - * Under very rare circumstances it may happen that the update - * queue will contain a job pointing to a node that has - * already been deleted from the image (direclty or by undo - * command). If it happens to a layer then the walker will - * handle it as usual by building a trivial graph pointing to - * nowhere, but when it happens to a mask... not. Because the - * mask is always expected to have a parent layer to process. - * - * So just handle it here separately. - */ - + /** + * Under very rare circumstances it may happen that the update + * queue will contain a job pointing to a node that has + * already been deleted from the image (direclty or by undo + * command). If it happens to a layer then the walker will + * handle it as usual by building a trivial graph pointing to + * nowhere, but when it happens to a mask... not. Because the + * mask is always expected to have a parent layer to process. + * + * So just handle it here separately. + */ + KisProjectionLeafSP parentLayer =3D filthyMask->parent(); + if (!parentLayer) { return; } = adjustMasksChangeRect(filthyMask); = - KisProjectionLeafSP parentLayer =3D filthyMask->parent(); - Q_ASSERT(parentLayer); - KisProjectionLeafSP nextLeaf =3D parentLayer->nextSibling(); KisProjectionLeafSP prevLeaf =3D parentLayer->prevSibling(); =20