Commit e4a584e3 authored by Niklas Haas's avatar Niklas Haas Committed by Hugo Beauzée-Luyssen
Browse files

libplacebo: fix use-after-free on uninit

`pl->ops->close` destroys the GPU instance, after which the swapchain is
undefined. Fix it by moving the swapchain destruction to `ops->close`
itself, where it can be done in the correct order.

(This also fixes a bug where, technically, the opengl instance attempted
destroying the swapchain while the context was not current on the
thread)
parent fe6ec4ce
......@@ -74,7 +74,6 @@ void vlc_placebo_Release(vlc_placebo_t *pl)
if (pl->ops)
pl->ops->close(pl);
pl_swapchain_destroy(&pl->swapchain);
pl_context_destroy(&pl->ctx);
/* TODO: use vlc_objres_clear */
......
......@@ -149,6 +149,7 @@ static void CloseInstance(vlc_placebo_t *pl)
if (sys->gl != NULL) {
if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS) {
pl_swapchain_destroy(&pl->swapchain);
pl_opengl_destroy(&sys->opengl);
vlc_gl_ReleaseCurrent(sys->gl);
}
......
......@@ -113,6 +113,7 @@ static void CloseInstance(vlc_placebo_t *pl)
{
vlc_placebo_system_t *sys = pl->sys;
pl_swapchain_destroy(&pl->swapchain);
pl_vulkan_destroy(&sys->vulkan);
pl_vk_inst_destroy(&sys->instance);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment