Skip to content

Commit

Permalink
Fix use of deallocated memory
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Dec 31, 2024
1 parent 03a2e7e commit b903825
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/x11/XGServerWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ - (BOOL) _checkStyle: (unsigned)style
XEvent xEvent;
unsigned long *extents;
Offsets *o = generic.offsets + (style & 15);
int windowIdent;
int repp = 0;
int repx = 0;
int repy = 0;
Expand Down Expand Up @@ -1131,14 +1132,19 @@ - (BOOL) _checkStyle: (unsigned)style
}
}

/* Calling termwindow should cause the window to be destroyed,
* so we need to take a copy of the window identifier to check
* for events left in the queue about that window.
*/
windowIdent = window->ident;
[self termwindow: window->number];
XSync(dpy, False);
while (XPending(dpy) > 0)
{
XNextEvent(dpy, &xEvent);
NSDebugLLog(@"Offset", @"Destroying ... event %d window %lu\n",
xEvent.type, xEvent.xany.window);
if (xEvent.xany.window != window->ident)
if (xEvent.xany.window != windowIdent)
{
continue;
}
Expand Down

0 comments on commit b903825

Please sign in to comment.