monitor-alignment: Do not crash on NULL display
Since commit 01b66ef88bc142d6716b40b1e384e94a2629a99f virt-viewer
does not crash on connection to a guest using an invalid display
configuration (eg. Cirrus & QXL vga). That commit allowed existence
of NULL display, however the code handling monitors alignment does
not expect this and crashes when virt-viewer is shifting/aligning
its windows.
Avoid crashing by returning early on NULL display.
#0 0x0000000000411d0a in displays_cmp (p1=p1@entry=0xbad940, p2=p2@entry=0xbad944, user_data=user_data@entry=0x8eb180) at virt-viewer-util.c:544
#1 0x00007ffff3f16ac5 in msort_with_tmp (p=0x7fffffffd670, b=0xbad940, n=2) at gqsort.c:93
#2 0x00007ffff3f16ded in msort_r (b=b@entry=0xbad940, n=n@entry=2, s=s@entry=4, cmp=cmp@entry=0x411ce0 <displays_cmp>, arg=arg@entry=0x8eb180) at gqsort.c:278
#3 0x00007ffff3f16e78 in g_qsort_with_data (pbase=pbase@entry=0xbad940, total_elems=total_elems@entry=2, size=size@entry=4, compare_func=compare_func@entry=0x411ce0 <displays_cmp>, user_data=user_data@entry=0x8eb180) at gqsort.c:303
#4 0x000000000041277c in virt_viewer_align_monitors_linear (displays=displays@entry=0x8eb180 = {...}) at virt-viewer-util.c:586
#5 0x000000000041a92d in virt_viewer_session_on_monitor_geometry_changed (self=0x8f38a0 [VirtViewerSessionSpice], display=<optimized out>) at virt-viewer-session.c:373
#6 0x00007ffff4415908 in g_closure_invoke (closure=0x9306c0, return_value=return_value@entry=0x0, n_param_values=2, param_values=param_values@entry=0x7fffffffd960, invocation_hint=invocation_hint@entry=0x7fffffffd900) at gclosure.c:801
#7 0x00007ffff4427a1d in signal_emit_unlocked_R (node=node@entry=0x668f80, detail=detail@entry=1551, instance=instance@entry=0x930440, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffd960) at gsignal.c:3627
#8 0x00007ffff442fab1 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffdaf0) at gsignal.c:3383
#9 0x00007ffff442fd9f in <emit signal notify:agent-connected on instance 0x930440 [SpiceMainChannel]> (instance=instance@entry=0x930440, signal_id=<optimized out>, detail=<optimized out>) at gsignal.c:3439
#10 0x00007ffff4419fd4 in g_object_dispatch_properties_changed (object=0x930440 [SpiceMainChannel], n_pspecs=<optimized out>, pspecs=<optimized out> at gobject.c:1061
#11 0x00007ffff441c4f9 in g_object_notify (pspec=<optimized out>, object=0x930440 [SpiceMainChannel]) at gobject.c:1155
#12 0x00007ffff441c4f9 in g_object_notify (object=0x930440 [SpiceMainChannel], property_name=<optimized out>) at gobject.c:1202
#13 0x00007ffff5a63dd0 in notify_main_context (opaque=0x7fffd6fde990) at gio-coroutine.c:240
#14 0x00007ffff3f07d7a in g_main_context_dispatch (context=0x68da40) at gmain.c:3152
#15 0x00007ffff3f07d7a in g_main_context_dispatch (context=context@entry=0x68da40) at gmain.c:3767
#16 0x00007ffff3f080b8 in g_main_context_iterate (context=0x68da40, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3838
#17 0x00007ffff3f0838a in g_main_loop_run (loop=0x710de0) at gmain.c:4032
#18 0x00007ffff5f53045 in gtk_main () at gtkmain.c:1207
#19 0x0000000000411a22 in main (argc=1, argv=0x7fffffffdfa8)
Resolves: rhbz#1250820
Acked-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Pavel Grunt authored 7 years ago
Fabiano FidĂȘncio committed 7 years ago
520 | 520 |
guint j = *(guint*)p2;
|
521 | 521 |
GdkRectangle *m1 = g_hash_table_lookup(displays, GINT_TO_POINTER(i));
|
522 | 522 |
GdkRectangle *m2 = g_hash_table_lookup(displays, GINT_TO_POINTER(j));
|
|
523 |
g_return_val_if_fail(m1 != NULL && m2 != NULL, 0);
|
523 | 524 |
diff = m1->x - m2->x;
|
524 | 525 |
if (diff == 0)
|
525 | 526 |
diff = m1->y - m2->y;
|
|
570 | 571 |
guint nth = sorted_displays[i];
|
571 | 572 |
g_assert(nth < ndisplays);
|
572 | 573 |
GdkRectangle *rect = g_hash_table_lookup(displays, GINT_TO_POINTER(nth));
|
|
574 |
g_return_if_fail(rect != NULL);
|
573 | 575 |
rect->x = x;
|
574 | 576 |
rect->y = 0;
|
575 | 577 |
x += rect->width;
|
|
602 | 604 |
g_hash_table_iter_init(&iter, displays);
|
603 | 605 |
while (g_hash_table_iter_next(&iter, NULL, &value)) {
|
604 | 606 |
GdkRectangle *display = value;
|
|
607 |
g_return_if_fail(display != NULL);
|
605 | 608 |
if (display->width > 0 && display->height > 0) {
|
606 | 609 |
xmin = MIN(xmin, display->x);
|
607 | 610 |
ymin = MIN(ymin, display->y);
|
100 | 100 |
{
|
101 | 101 |
0, {NULL}, {NULL}, 0, {NULL}
|
102 | 102 |
},{
|
|
103 |
1,
|
|
104 |
{NULL},
|
|
105 |
{NULL},
|
|
106 |
G_LOG_LEVEL_CRITICAL,
|
|
107 |
{"*assertion 'display != NULL' failed"}
|
|
108 |
},{
|
|
109 |
2,
|
|
110 |
{NULL, &rects[0]},
|
|
111 |
{NULL, &rects[0]},
|
|
112 |
G_LOG_LEVEL_CRITICAL,
|
|
113 |
{"*assertion 'display != NULL' failed"}
|
|
114 |
},{
|
|
115 |
2,
|
|
116 |
{&rects[2], NULL},
|
|
117 |
{&rects[2], NULL},
|
|
118 |
G_LOG_LEVEL_CRITICAL,
|
|
119 |
{"*assertion 'display != NULL' failed"}
|
|
120 |
},{
|
103 | 121 |
2,
|
104 | 122 |
{&rects[0], &rects[0]},
|
105 | 123 |
{&rects[1], &rects[1]},
|
|
139 | 157 |
{
|
140 | 158 |
0, {NULL}, {NULL}, 0, {NULL}
|
141 | 159 |
},{
|
|
160 |
1,
|
|
161 |
{NULL},
|
|
162 |
{NULL},
|
|
163 |
G_LOG_LEVEL_CRITICAL,
|
|
164 |
{"*assertion 'rect != NULL' failed"}
|
|
165 |
},{
|
|
166 |
2,
|
|
167 |
{NULL, &rects[1]},
|
|
168 |
{NULL, &rects[1]},
|
|
169 |
G_LOG_LEVEL_CRITICAL,
|
|
170 |
{
|
|
171 |
"*displays_cmp: assertion 'm1 != NULL && m2 != NULL' failed",
|
|
172 |
"*assertion 'rect != NULL' failed"
|
|
173 |
}
|
|
174 |
},{
|
|
175 |
3,
|
|
176 |
{&rects[1], NULL, &rects[0]},
|
|
177 |
{&rects[3], NULL, &rects[0]},
|
|
178 |
G_LOG_LEVEL_CRITICAL,
|
|
179 |
{
|
|
180 |
"*displays_cmp: assertion 'm1 != NULL && m2 != NULL' failed",
|
|
181 |
"*displays_cmp: assertion 'm1 != NULL && m2 != NULL' failed",
|
|
182 |
"*assertion 'rect != NULL' failed"
|
|
183 |
}
|
|
184 |
},{
|
142 | 185 |
2,
|
143 | 186 |
{&rects[0], &rects[1]},
|
144 | 187 |
{&rects[0], &rects[2]},
|