Fix "heap-use-after-free" in resize_after_screen_change() (#1248)

When a native window is destroyed, make sure the callback to
Fl_WinAPI_Window_Driver::resize_after_screen_change() is removed.

Added by Albrecht-S:

Thanks for the original fix to Timothy Lee (@timothytylee).

src/drivers/X11/Fl_X11_Window_Driver.cxx: equivalent fix for X11
  as discussed on GitHub PR #1248
This commit is contained in:
Timothy Lee 2025-04-11 21:17:19 +10:00 committed by Albrecht Schlosser
parent 219c623b4b
commit 002b69f8fe
2 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,7 @@
//
// Definition of Windows window driver for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2022 by Bill Spitzak and others.
// Copyright 1998-2025 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -50,6 +50,7 @@ Fl_WinAPI_Window_Driver::Fl_WinAPI_Window_Driver(Fl_Window *win)
Fl_WinAPI_Window_Driver::~Fl_WinAPI_Window_Driver()
{
Fl::remove_timeout(resize_after_screen_change, pWindow);
if (shape_data_) {
delete shape_data_->effective_bitmap_;
delete shape_data_;
@ -475,7 +476,7 @@ void Fl_WinAPI_Window_Driver::hide() {
// Issue #569: undo RegisterDragDrop()
RevokeDragDrop((HWND)ip->xid);
fl_i_own_selection[1] = 0; // issue #1233
// make sure any custom icons get freed

View File

@ -58,6 +58,7 @@ Fl_X11_Window_Driver::Fl_X11_Window_Driver(Fl_Window *win)
Fl_X11_Window_Driver::~Fl_X11_Window_Driver()
{
Fl::remove_timeout(resize_after_screen_change, pWindow);
if (shape_data_) {
delete shape_data_->effective_bitmap_;
delete shape_data_;