From 2dd9dfc8d9a5dc906ee06d667a756ab267f55e64 Mon Sep 17 00:00:00 2001 From: Alex Goins Date: Wed, 4 Sep 2019 12:25:31 -0500 Subject: [PATCH] randr: Fix RRCrtcDetachScanoutPixmap() segfault during server teardown During server teardown, mrootdraw is NULL, which can cause segfaults if master->Stop{,Flipping}PixmapTracking() don't do NULL checking. In this case we shouldn't need to do master->Stop{,Flipping}PixmapTracking() anyway, so just skip it. Signed-off-by: Alex Goins (cherry picked from commit c82f814313a813d7e1a2d7d3b1f7561810446b34) --- randr/rrcrtc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index a851aebcc..ae7e30605 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -401,17 +401,22 @@ RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc) if (crtc->scanout_pixmap_back) { pScrPriv->rrDisableSharedPixmapFlipping(crtc); - master->StopFlippingPixmapTracking(mrootdraw, - crtc->scanout_pixmap, - crtc->scanout_pixmap_back); + if (mrootdraw) { + master->StopFlippingPixmapTracking(mrootdraw, + crtc->scanout_pixmap, + crtc->scanout_pixmap_back); + } rrDestroySharedPixmap(crtc, crtc->scanout_pixmap_back); crtc->scanout_pixmap_back = NULL; } else { pScrPriv->rrCrtcSetScanoutPixmap(crtc, NULL); - master->StopPixmapTracking(mrootdraw, - crtc->scanout_pixmap); + + if (mrootdraw) { + master->StopPixmapTracking(mrootdraw, + crtc->scanout_pixmap); + } } rrDestroySharedPixmap(crtc, crtc->scanout_pixmap);