vnc: Fix qemu crashed when vnc client disconnect suddenly
commite3c1adf16e38714ebd761dd02517dd07760ba6d2
authorGonglei (Arei) <arei.gonglei@huawei.com>
Thu, 23 Jan 2014 13:30:57 +0000 (23 13:30 +0000)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 10 Mar 2014 11:35:04 +0000 (10 12:35 +0100)
tree7a71fd3e1120bd4b307339217ad1f48777e98f55
parent2e7bcdb99adbd8fc10ad9ddcf93bd2bf3c0f1f2d
vnc: Fix qemu crashed when vnc client disconnect suddenly

Hi,

When I use RealVNC viewer client (http://www.realvnc.com/) to connect vnc server,
the client disconnect suddenly, and I click reconnect button immediately, then the Qemu crashed.

In the function vnc_worker_thread_loop, will call vnc_async_encoding_start
to set the local vs->output buffer by global queue's buffer. Then send rectangles to
the vnc client call function vnc_send_framebuffer_update. Finally, Under normal circumstances,
call vnc_async_encoding_end to set the global queue'buffer by the local vs->output conversely.

When the vnc client disconnect, the job->vs->csock will be set to -1. And the current prcoess
logic will goto disconnected partion without call function vnc_async_encoding_end.
But, the function vnc_send_framebuffer_update will call buffer_reserve, which
maybe call g_realloc reset the local vs's buffer, meaning the global queue's buffer is modified also.
If anyone use the original global queue's buffer memory will cause corruption and then crash qemu.

This patch assure the function vnc_async_encoding_end being called
even though the vnc client disconnect suddenly.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ui/vnc-jobs.c