summaryrefslogtreecommitdiff
path: root/vdagent
diff options
context:
space:
mode:
authorUri Lublin <uril@redhat.com>2013-05-09 17:17:52 +0300
committerArnon Gilboa <agilboa@redhat.com>2013-05-12 12:43:25 +0300
commit08a23eb45b1a2afdecc3ffa893873032c88718c4 (patch)
tree6734c969675cc6148764c12e0dc63841bf02873b /vdagent
parentb72b943309089a0c9340969f4c5bbea2e1500236 (diff)
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.
Diffstat (limited to 'vdagent')
-rw-r--r--vdagent/desktop_layout.cpp7
-rw-r--r--vdagent/vdagent.cpp9
2 files changed, 11 insertions, 5 deletions
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) {