egl/haiku: fix double free of BBitmap

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30364>
(cherry picked from commit 2e70757dc0)
This commit is contained in:
X512 2024-07-25 22:26:25 +09:00 committed by Eric Engestrom
parent 1ac0f451d9
commit 86c5feed5c
2 changed files with 11 additions and 1 deletions

View File

@ -1464,7 +1464,7 @@
"description": "egl/haiku: fix double free of BBitmap",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View File

@ -115,6 +115,9 @@ haiku_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf,
return NULL;
}
// Unset and delete previously set bitmap if any.
delete ((BitmapHook *)native_window)->SetBitmap(NULL);
return &wgl_surf->base;
}
@ -168,6 +171,13 @@ haiku_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf)
struct haiku_egl_surface *hgl_surf = haiku_egl_surface(surf);
struct pipe_screen *screen = hgl_dpy->disp->fscreen->screen;
screen->fence_reference(screen, &hgl_surf->throttle_fence, NULL);
// Unset bitmap to release ownership. Bitmap will be deleted later
// when destroying framebuffer.
BitmapHook *bitmapHook = (BitmapHook*)hgl_surf->fb->winsysContext;
if (bitmapHook != NULL)
bitmapHook->SetBitmap(NULL);
hgl_destroy_st_framebuffer(hgl_surf->fb);
free(surf);
}