From: Pierre Ossman Date: Fri, 5 Jul 2024 12:05:45 +0000 (+0200) Subject: Be more careful with ComparingUpdateTracker pointer X-Git-Tag: v1.14.0~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8d0389d2a1367fba677212882ce89d9e71cf9460;p=tigervnc.git Be more careful with ComparingUpdateTracker pointer As of 28c3f12, we might now be running the frame clock even without a framebuffer present. This means we need to be more careful accessing the ComparingUpdateTracker, as it might be NULL. (cherry picked from commit c4075860579ad33011fafee32f34c5d3da71a910) --- diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index b9579f12..38318120 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -643,7 +643,8 @@ void VNCServerST::handleTimeout(Timer* t) // We keep running until we go a full interval without any updates, // or there are no active clients anymore - if (comparer->is_empty() || !desktopStarted) { + if (!desktopStarted || + ((comparer != NULL) && comparer->is_empty())) { // Unless something waits for us to advance the frame count if (queuedMsc < msc) return; @@ -658,7 +659,8 @@ void VNCServerST::handleTimeout(Timer* t) frameTimer.repeat(timeout); - if (!comparer->is_empty() && desktopStarted) + if (desktopStarted && + ((comparer != NULL) && !comparer->is_empty())) writeUpdate(); msc++; @@ -742,6 +744,7 @@ void VNCServerST::startDesktop() desktopStarted = true; // The tracker might have accumulated changes whilst we were // stopped, so flush those out + assert(comparer != NULL); if (!comparer->is_empty()) writeUpdate(); // If the frame clock is running, then it will be running slowly, @@ -788,8 +791,11 @@ void VNCServerST::startFrameClock() return; // Anyone actually interested in frames? - if (comparer->is_empty() && (queuedMsc <= msc)) - return; + if (!desktopStarted || + ((comparer != NULL) && comparer->is_empty())) { + if (queuedMsc < msc) + return; + } // Run the frame clock very slowly if there are no clients to actually // send updates to @@ -836,6 +842,7 @@ void VNCServerST::writeUpdate() assert(blockCounter == 0); assert(desktopStarted); + assert(comparer != NULL); comparer->getUpdateInfo(&ui, pb->getRect()); toCheck = ui.changed.union_(ui.copied); @@ -880,6 +887,8 @@ Region VNCServerST::getPendingRegion() if (blockCounter > 0) return pb->getRect(); + assert(comparer != NULL); + // Block client from updating if there are pending updates if (comparer->is_empty()) return Region();