Codebase list virt-viewer / cb4ec1f
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
2 changed file(s) with 46 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
520520 guint j = *(guint*)p2;
521521 GdkRectangle *m1 = g_hash_table_lookup(displays, GINT_TO_POINTER(i));
522522 GdkRectangle *m2 = g_hash_table_lookup(displays, GINT_TO_POINTER(j));
523 g_return_val_if_fail(m1 != NULL && m2 != NULL, 0);
523524 diff = m1->x - m2->x;
524525 if (diff == 0)
525526 diff = m1->y - m2->y;
570571 guint nth = sorted_displays[i];
571572 g_assert(nth < ndisplays);
572573 GdkRectangle *rect = g_hash_table_lookup(displays, GINT_TO_POINTER(nth));
574 g_return_if_fail(rect != NULL);
573575 rect->x = x;
574576 rect->y = 0;
575577 x += rect->width;
602604 g_hash_table_iter_init(&iter, displays);
603605 while (g_hash_table_iter_next(&iter, NULL, &value)) {
604606 GdkRectangle *display = value;
607 g_return_if_fail(display != NULL);
605608 if (display->width > 0 && display->height > 0) {
606609 xmin = MIN(xmin, display->x);
607610 ymin = MIN(ymin, display->y);
100100 {
101101 0, {NULL}, {NULL}, 0, {NULL}
102102 },{
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 },{
103121 2,
104122 {&rects[0], &rects[0]},
105123 {&rects[1], &rects[1]},
139157 {
140158 0, {NULL}, {NULL}, 0, {NULL}
141159 },{
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 },{
142185 2,
143186 {&rects[0], &rects[1]},
144187 {&rects[0], &rects[2]},