Commit 9613a90d authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Fix crash when using VNC session

When running under a VNC session, the connection setup data sometimes
has duplicated depths, like so:

depth=24: visuals={123,456}
depth=24: visuals={789}

Previously, we were searching for the unique depth that matches the
root depth, then searching for the visual within the list
corresponding to that depth.  However, since the depths may not be
unique, search through all depths until we find a matching visual ID,
and then use that to set both the default depth and default visual.

R=sky

Change-Id: I51f75260f584f85f2bdc93048e6c4848cf00997a
Fixes: 1121438, 1115929
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375888Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802371}
parent d85c1f49
......@@ -238,16 +238,7 @@ Connection::Connection(const std::string& address)
xcb_get_setup(XcbConnection())));
setup_ = Read<Setup>(&buf);
default_screen_ = &setup_.roots[DefaultScreenId()];
default_root_depth_ = &*std::find_if(
default_screen_->allowed_depths.begin(),
default_screen_->allowed_depths.end(), [&](const Depth& depth) {
return depth.depth == default_screen_->root_depth;
});
default_root_visual_ = &*std::find_if(
default_root_depth_->visuals.begin(),
default_root_depth_->visuals.end(), [&](const VisualType visual) {
return visual.visual_id == default_screen_->root_visual;
});
InitRootDepthAndVisual();
} else {
// Default-initialize the setup data so we always have something to return.
setup_.roots.emplace_back();
......@@ -470,6 +461,19 @@ void Connection::Dispatch(Delegate* delegate) {
}
}
void Connection::InitRootDepthAndVisual() {
for (auto& depth : default_screen_->allowed_depths) {
for (auto& visual : depth.visuals) {
if (visual.visual_id == default_screen_->root_visual) {
default_root_depth_ = &depth;
default_root_visual_ = &visual;
return;
}
}
}
NOTREACHED();
}
void Connection::AddRequest(unsigned int sequence,
FutureBase::ResponseCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -149,6 +149,8 @@ class COMPONENT_EXPORT(X11) Connection : public XProto,
FutureBase::ResponseCallback callback;
};
void InitRootDepthAndVisual();
void AddRequest(unsigned int sequence, FutureBase::ResponseCallback callback);
bool HasNextResponse() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment