From: Kai Ma Date: Sat, 3 Dec 2022 10:17:26 +0000 (+0800) Subject: Prevent a segfault when deleting a fullscreen frame on NextStep. X-Git-Tag: emacs-29.0.90~1353 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=029988d4a51;p=emacs.git Prevent a segfault when deleting a fullscreen frame on NextStep. * nsterm.m ([EmacsView resetCursorRects:]): Be defensive when accessing FRAME_OUTPUT_DATA. [resetCursorRects:] can be called from the event loop after the frame is deleted. When this happens, emacsframe is NULL. This means there is an underlying leak of the EmacsView object! (Bug#59794) Do not merge to master. Copyright-paperwork-exempt: yes --- diff --git a/src/nsterm.m b/src/nsterm.m index 507f2a9e7da..c09f743ec7f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6703,8 +6703,16 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action) - (void)resetCursorRects { - NSRect visible = [self visibleRect]; - NSCursor *currentCursor = FRAME_POINTER_TYPE (emacsframe); + NSRect visible; + NSCursor *currentCursor; + + /* On macOS 13, [resetCursorRects:] could be called even after the + window is closed. */ + if (! emacsframe || ! FRAME_OUTPUT_DATA (emacsframe)) + return; + + visible = [self visibleRect]; + currentCursor = FRAME_POINTER_TYPE (emacsframe); NSTRACE ("[EmacsView resetCursorRects]"); if (currentCursor == nil)