Skip to content

Commit

Permalink
Be more careful with ComparingUpdateTracker pointer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CendioOssman committed Jul 5, 2024
1 parent c831c90 commit c407586
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions common/rfb/VNCServerST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,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 != nullptr) && comparer->is_empty())) {
// Unless something waits for us to advance the frame count
if (queuedMsc < msc)
return;
Expand All @@ -642,7 +643,8 @@ void VNCServerST::handleTimeout(Timer* t)

frameTimer.repeat(timeout);

if (!comparer->is_empty() && desktopStarted)
if (desktopStarted &&
((comparer != nullptr) && !comparer->is_empty()))
writeUpdate();

msc++;
Expand Down Expand Up @@ -726,6 +728,7 @@ void VNCServerST::startDesktop()
desktopStarted = true;
// The tracker might have accumulated changes whilst we were
// stopped, so flush those out
assert(comparer != nullptr);
if (!comparer->is_empty())
writeUpdate();
// If the frame clock is running, then it will be running slowly,
Expand Down Expand Up @@ -772,8 +775,11 @@ void VNCServerST::startFrameClock()
return;

// Anyone actually interested in frames?
if (comparer->is_empty() && (queuedMsc <= msc))
return;
if (!desktopStarted ||
((comparer != nullptr) && comparer->is_empty())) {
if (queuedMsc < msc)
return;
}

// Run the frame clock very slowly if there are no clients to actually
// send updates to
Expand Down Expand Up @@ -820,6 +826,7 @@ void VNCServerST::writeUpdate()

assert(blockCounter == 0);
assert(desktopStarted);
assert(comparer != nullptr);

comparer->getUpdateInfo(&ui, pb->getRect());
toCheck = ui.changed.union_(ui.copied);
Expand Down Expand Up @@ -863,6 +870,8 @@ Region VNCServerST::getPendingRegion()
if (blockCounter > 0)
return pb->getRect();

assert(comparer != nullptr);

// Block client from updating if there are pending updates
if (comparer->is_empty())
return Region();
Expand Down

0 comments on commit c407586

Please sign in to comment.