From be91342733fd56d1e7bafe72e82a8ac4dc67b79d Mon Sep 17 00:00:00 2001 From: kasull Date: Tue, 3 Mar 2026 18:49:43 -0500 Subject: fix use after free --- src/editor/editor.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/editor/editor.cpp') diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index 63360d1..3873913 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -4,6 +4,31 @@ GAME_EDITOR* editor = 0; +void editor_clear_gui_state_refs( GAME_EDITOR* e ) { + if( !e ) + return; + + e->gui.new_map_popup = 0; + + e->gui.v2d = 0; + e->gui.v3d = 0; + e->gui.gridlabel = 0; + e->gui.props = 0; + e->gui.tool = 0; + + e->gui.assets = 0; + e->gui.status = 0; + e->gui.assets_scroll = 0; + + e->gui.header_toolbar = 0; + e->gui.header_viewtype_label = 0; + e->gui.header_back = 0; + e->gui.header_mode_2d = 0; + e->gui.header_mode_3d = 0; + e->gui.header_mode_sim = 0; + e->gui.header_viewtype = 0; +} + static void editor_push_undo_action( GAME_EDITOR* e, const GAME_EDITOR::EDITOR_UNDO_ACTION& action ) { if( !e ) return; @@ -410,6 +435,7 @@ STAT editor_close( GAME_EDITOR* e ) { I32 w = e->wnd->w, h = e->wnd->h; gui_free( e->wnd ); + editor_clear_gui_state_refs( e ); e->wnd = gui_editorwindow( w, h ); } ); -- cgit v1.2.3