From 65ee3248f52e64fea482114f87317a842f500ae6 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Mon, 2 Jan 2023 22:33:00 -0800 Subject: [PATCH] rootless: Ensure gResizeDeathPix is stored in locally-managed memory rather than re-using the implementation's backing store The implementation owns the pointer during RootlessStopDrawing and RootlessStartDrawing and is free to (does) change it. Rootless cannot assume ownership of this memory region. This is possibly the cause of some hard to diagnose crashes in XQuartz over the years. Signed-off-by: Jeremy Huddleston Sequoia --- miext/rootless/rootlessWindow.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index bacab4cb7..5e371e0d1 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -1012,7 +1012,12 @@ StartFrameResize(WindowPtr pWin, Bool gravity, } else if (gravity) { /* The general case. Just copy everything. */ + need_window_source = TRUE; + } + /* If necessary, create a source pixmap pointing at the current + window bits. */ + if (need_window_source) { RootlessStartDrawing(pWin); gResizeDeathBits = xallocarray(winRec->bytesPerRow, winRec->height); @@ -1054,21 +1059,6 @@ StartFrameResize(WindowPtr pWin, Bool gravity, RootlessStartDrawing(pWin); - /* If necessary, create a source pixmap pointing at the current - window bits. */ - - if (need_window_source) { - gResizeDeathBounds[0] = (BoxRec) { - oldX, oldY, oldX2, oldY2}; - gResizeDeathPix[0] - = GetScratchPixmapHeader(pScreen, oldW, oldH, - winRec->win->drawable.depth, - winRec->win->drawable.bitsPerPixel, - winRec->bytesPerRow, winRec->pixelData); - - SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY); - } - /* Use custom CopyWindow when moving gravity bits around ResizeWindow assumes the old window contents are in the same pixmap, but here they're in deathPix instead. */