mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 22:06:45 +00:00
loadingscreen: Fix UaF in loading screen.
When the CopyFramebufferToTextureCallback callback is called, in its operator() it resets setInitialDrawCallback by providing a NULL pointer. However, this causes the callback to get deleted. In turn, the "this" pointer is invalidated. When execution returns to DrawCallback::run, it accesses a _nestedCallback member of deleted "this" which is UB.
This commit is contained in:
parent
a037e4c954
commit
8e7c01b561
1 changed files with 2 additions and 4 deletions
|
@ -141,10 +141,6 @@ namespace MWGui
|
||||||
int w = renderInfo.getCurrentCamera()->getViewport()->width();
|
int w = renderInfo.getCurrentCamera()->getViewport()->width();
|
||||||
int h = renderInfo.getCurrentCamera()->getViewport()->height();
|
int h = renderInfo.getCurrentCamera()->getViewport()->height();
|
||||||
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
|
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
|
||||||
|
|
||||||
// Callback removes itself when done
|
|
||||||
if (renderInfo.getCurrentCamera())
|
|
||||||
renderInfo.getCurrentCamera()->setInitialDrawCallback(nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -308,6 +304,8 @@ namespace MWGui
|
||||||
mGuiTexture.reset(new osgMyGUI::OSGTexture(mTexture));
|
mGuiTexture.reset(new osgMyGUI::OSGTexture(mTexture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notice that the next time this is called, the current CopyFramebufferToTextureCallback will be deleted
|
||||||
|
// so there's no memory leak as at most one object of type CopyFramebufferToTextureCallback is allocated at a time.
|
||||||
mViewer->getCamera()->setInitialDrawCallback(new CopyFramebufferToTextureCallback(mTexture));
|
mViewer->getCamera()->setInitialDrawCallback(new CopyFramebufferToTextureCallback(mTexture));
|
||||||
|
|
||||||
mBackgroundImage->setBackgroundImage("");
|
mBackgroundImage->setBackgroundImage("");
|
||||||
|
|
Loading…
Reference in a new issue