diff --git a/.pick_status.json b/.pick_status.json index d675ab1e0c4..baf3b1697e8 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/egl/drivers/haiku/egl_haiku.cpp b/src/egl/drivers/haiku/egl_haiku.cpp index 15417767406..62d2fb5c3cd 100644 --- a/src/egl/drivers/haiku/egl_haiku.cpp +++ b/src/egl/drivers/haiku/egl_haiku.cpp @@ -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); }