[Spice-commits] vdagent/desktop_layout.cpp vdagent/vdagent.cpp
Arnon Gilboa
agilboa at kemper.freedesktop.org
Sun May 12 02:33:59 PDT 2013
vdagent/desktop_layout.cpp | 7 +++++--
vdagent/vdagent.cpp | 9 ++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
New commits:
commit 08a23eb45b1a2afdecc3ffa893873032c88718c4
Author: Uri Lublin <uril at redhat.com>
Date: Thu May 9 17:17:52 2013 +0300
vdagent: protect against NULL entry in _displays
rhbz#958051
It may be that a _displays entry will be NULL.
I encountered it when running with multiple QXL devices, for one of
which the driver failed to load since it was "out of resources".
Iterations over _displays should handle that case.
We found four such iterations, and fixed them in this patch.
diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index c474edb..26b6b53 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -155,7 +155,7 @@ void DesktopLayout::normalize_displays_pos()
for (iter = _displays.begin(); iter != _displays.end(); iter++) {
mode = *iter;
- if (mode->_attached) {
+ if (mode && mode->_attached) {
min_x = min(min_x, mode->_pos_x);
min_y = min(min_y, mode->_pos_y);
max_x = max(max_x, mode->_pos_x + (LONG)mode->_width);
@@ -164,7 +164,10 @@ void DesktopLayout::normalize_displays_pos()
}
if (min_x || min_y) {
for (iter = _displays.begin(); iter != _displays.end(); iter++) {
- (*iter)->move_pos(-min_x, -min_y);
+ mode = *iter;
+ if (mode) {
+ mode->move_pos(-min_x, -min_y);
+ }
}
}
_total_width = max_x - min_x;
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 75291b0..a061973 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -618,7 +618,9 @@ bool VDAgent::handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port
display_count = _desktop_layout->get_display_count();
for (uint32_t i = 0; i < display_count; i++) {
DisplayMode* mode = _desktop_layout->get_display(i);
- ASSERT(mode);
+ if (!mode) {
+ continue;
+ }
if (i >= mon_config->num_of_monitors) {
vd_printf("%d. detached", i);
mode->set_attached(false);
@@ -748,8 +750,9 @@ void VDAgent::set_display_depth(uint32_t depth)
// setting depth for all the monitors, including unattached ones
for (uint32_t i = 0; i < display_count; i++) {
DisplayMode* mode = _desktop_layout->get_display(i);
- ASSERT(mode);
- mode->set_depth(depth);
+ if (mode) {
+ mode->set_depth(depth);
+ }
}
if (display_count) {
More information about the Spice-commits
mailing list