From nobody Mon Feb 9 08:20:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=163.com ARC-Seal: i=1; a=rsa-sha256; t=1567266121; cv=none; d=zoho.com; s=zohoarc; b=nO4aK2cedd4bo27pNbrCpe1XGb1Qqv5dZb+hChNaf+adfK3UIalL+yWy2SfKONEo8fHFYox+h7+eBb5eKEubvUc3OH7gL+MBCj2VCT11aMV1YEQx4e3fZqf/K5Jijj9adpQs/j8+2LwbH2WjyPWhW5joDtPDVRx/jI/3VOPxRU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567266121; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=tqp+edCW3i7Blr7I7hJkhEfBif4m88D2KjbiNHLjaIg=; b=IjOj3wGBYSvldDEPnhKlpQRecdM/z796FVva/4Z9daaZ/7V/yFAciNsgrpOdgrupiclpQ2SR6tO624YW9bXIXhvGzdxkZIIHnAK0F4iuHz33BEtKAukgpHigrt3phILGfWRJHj6I42/KUZOULW2rnxDVN7MCeX+b5/6/ouy6Zco= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567266121047376.2692511885765; Sat, 31 Aug 2019 08:42:01 -0700 (PDT) Received: from localhost ([::1]:45366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i45Vi-0003TH-Kq for importer@patchew.org; Sat, 31 Aug 2019 11:41:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49572) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i45Tv-0002Xg-5M for qemu-devel@nongnu.org; Sat, 31 Aug 2019 11:40:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i45To-0001G6-Tb for qemu-devel@nongnu.org; Sat, 31 Aug 2019 11:40:00 -0400 Received: from m12-16.163.com ([220.181.12.16]:38864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i45Tm-00014e-Hw for qemu-devel@nongnu.org; Sat, 31 Aug 2019 11:39:56 -0400 Received: from localhost.localdomain (unknown [183.158.152.47]) by smtp12 (Coremail) with SMTP id EMCowAAnPo62lGpdQPXXAA--.20606S2; Sat, 31 Aug 2019 23:39:35 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=tqp+edCW3i7Blr7I7h JkhEfBif4m88D2KjbiNHLjaIg=; b=WlrmE4w+m3zCl2Umb3G9sYAOf7U7D1VWEJ 5trI9QS+16FwirgsF8KSkTIcyoFrnSyUTk2Ycn6LlQUD5B2q2dpEEsV9B7UXL7Il X8rP8vp5JihQW6qQcpb0F8jANsAriekjvI1TzXAaYVSZZO58o9SjyiWHAShOBLHJ w4ecBGtHo= From: Li Qiang To: kraxel@redhat.com, fangying1@huawei.com Date: Sat, 31 Aug 2019 08:39:22 -0700 Message-Id: <20190831153922.121308-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: EMCowAAnPo62lGpdQPXXAA--.20606S2 X-Coremail-Antispam: 1Uf129KBjvAXoWfCw4fCFyxtrWrWrWfGFWfZrb_yoW5Kw4xZo WYq3yktw4DKF1UCF18t3W8Ww1jqF4DK3yDAF48ur1DZ3W7Aws09Fy7Z3Z5ta45GF4jkrWf Jr18Kw4rtFnrJrWfn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU0tx6DUUUU X-Originating-IP: [183.158.152.47] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiTw8ibVsGREboLgAAsW X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.16 Subject: [Qemu-devel] [PATCH] vnc: fix memory leak when vnc disconnect X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently when qemu receives a vnc connect, it creates a 'VncState' to represent this connection. In 'vnc_worker_thread_loop' it creates a local 'VncState'. The connection 'VcnState' and local 'VncState' exchange data in 'vnc_async_encoding_start' and 'vnc_async_encoding_end'. In 'zrle_compress_data' it calls 'deflateInit2' to allocate the libz library opaque data. The 'VncState' used in 'zrle_compress_data' is the local 'VncState'. In 'vnc_zrle_clear' it calls 'deflateEnd' to free the libz library opaque data. The 'VncState' used in 'vnc_zrle_clear' is the connect= ion 'VncState'. In currently implementation there will be a memory leak when the vnc disconnect. Following is the asan output backtrack: Direct leak of 29760 byte(s) in 5 object(s) allocated from: 0 0xffffa67ef3c3 in __interceptor_calloc (/lib64/libasan.so.4+0xd33c3) 1 0xffffa65071cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) 2 0xffffa5e968f7 in deflateInit2_ (/lib64/libz.so.1+0x78f7) 3 0xaaaacec58613 in zrle_compress_data ui/vnc-enc-zrle.c:87 4 0xaaaacec58613 in zrle_send_framebuffer_update ui/vnc-enc-zrle.c:344 5 0xaaaacec34e77 in vnc_send_framebuffer_update ui/vnc.c:919 6 0xaaaacec5e023 in vnc_worker_thread_loop ui/vnc-jobs.c:271 7 0xaaaacec5e5e7 in vnc_worker_thread ui/vnc-jobs.c:340 8 0xaaaacee4d3c3 in qemu_thread_start util/qemu-thread-posix.c:502 9 0xffffa544e8bb in start_thread (/lib64/libpthread.so.0+0x78bb) 10 0xffffa53965cb in thread_start (/lib64/libc.so.6+0xd55cb) This is because the opaque allocated in 'deflateInit2' is not freed in 'deflateEnd'. The reason is that the 'deflateEnd' calls 'deflateStateCheck' and in the latter will check whether 's->strm !=3D strm'(libz's data struct= ure). This check will be true so in 'deflateEnd' it just return 'Z_STREAM_ERROR' = and not free the data allocated in 'deflateInit2'. The reason this happens is that the 'VncState' contains the whole 'VncZrle', so when calling 'deflateInit2', the 's->strm' will be the local address. So 's->strm !=3D strm' will be true. To fix this issue, we need to make 'zrle' of 'VncState' to be a pointer. Then the connection 'VncState' and local 'VncState' exchange mechanism will work as expection. The 'tight' of 'VncState' has the same issue, let's also= turn it to a pointer. Reported-by: Ying Fang Signed-off-by: Li Qiang --- ui/vnc-enc-tight.c | 219 +++++++++++++++++++++--------------------- ui/vnc-enc-zlib.c | 11 ++- ui/vnc-enc-zrle.c | 68 ++++++------- ui/vnc-enc-zrle.inc.c | 2 +- ui/vnc.c | 28 +++--- ui/vnc.h | 4 +- 6 files changed, 170 insertions(+), 162 deletions(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 9084c2201b..1e0851826a 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -116,7 +116,7 @@ static int send_png_rect(VncState *vs, int x, int y, in= t w, int h, =20 static bool tight_can_send_png_rect(VncState *vs, int w, int h) { - if (vs->tight.type !=3D VNC_ENCODING_TIGHT_PNG) { + if (vs->tight->type !=3D VNC_ENCODING_TIGHT_PNG) { return false; } =20 @@ -144,7 +144,7 @@ tight_detect_smooth_image24(VncState *vs, int w, int h) int pixels =3D 0; int pix, left[3]; unsigned int errors; - unsigned char *buf =3D vs->tight.tight.buffer; + unsigned char *buf =3D vs->tight->tight.buffer; =20 /* * If client is big-endian, color samples begin from the second @@ -215,7 +215,7 @@ tight_detect_smooth_image24(VncState *vs, int w, int h) int pixels =3D 0; \ int sample, sum, left[3]; \ unsigned int errors; \ - unsigned char *buf =3D vs->tight.tight.buffer; \ + unsigned char *buf =3D vs->tight->tight.buffer; = \ \ endian =3D 0; /* FIXME */ \ \ @@ -296,8 +296,8 @@ static int tight_detect_smooth_image(VncState *vs, int w, int h) { unsigned int errors; - int compression =3D vs->tight.compression; - int quality =3D vs->tight.quality; + int compression =3D vs->tight->compression; + int quality =3D vs->tight->quality; =20 if (!vs->vd->lossy) { return 0; @@ -309,7 +309,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h) return 0; } =20 - if (vs->tight.quality !=3D (uint8_t)-1) { + if (vs->tight->quality !=3D (uint8_t)-1) { if (w * h < VNC_TIGHT_JPEG_MIN_RECT_SIZE) { return 0; } @@ -320,9 +320,9 @@ tight_detect_smooth_image(VncState *vs, int w, int h) } =20 if (vs->client_pf.bytes_per_pixel =3D=3D 4) { - if (vs->tight.pixel24) { + if (vs->tight->pixel24) { errors =3D tight_detect_smooth_image24(vs, w, h); - if (vs->tight.quality !=3D (uint8_t)-1) { + if (vs->tight->quality !=3D (uint8_t)-1) { return (errors < tight_conf[quality].jpeg_threshold24); } return (errors < tight_conf[compression].gradient_threshold24); @@ -352,7 +352,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h) uint##bpp##_t c0, c1, ci; \ int i, n0, n1; \ \ - data =3D (uint##bpp##_t *)vs->tight.tight.buffer; \ + data =3D (uint##bpp##_t *)vs->tight->tight.buffer; \ \ c0 =3D data[0]; \ i =3D 1; \ @@ -423,9 +423,9 @@ static int tight_fill_palette(VncState *vs, int x, int = y, { int max; =20 - max =3D count / tight_conf[vs->tight.compression].idx_max_colors_divis= or; + max =3D count / tight_conf[vs->tight->compression].idx_max_colors_divi= sor; if (max < 2 && - count >=3D tight_conf[vs->tight.compression].mono_min_rect_size) { + count >=3D tight_conf[vs->tight->compression].mono_min_rect_size) { max =3D 2; } if (max >=3D 256) { @@ -558,7 +558,7 @@ tight_filter_gradient24(VncState *vs, uint8_t *buf, int= w, int h) int x, y, c; =20 buf32 =3D (uint32_t *)buf; - memset(vs->tight.gradient.buffer, 0, w * 3 * sizeof(int)); + memset(vs->tight->gradient.buffer, 0, w * 3 * sizeof(int)); =20 if (1 /* FIXME */) { shift[0] =3D vs->client_pf.rshift; @@ -575,7 +575,7 @@ tight_filter_gradient24(VncState *vs, uint8_t *buf, int= w, int h) upper[c] =3D 0; here[c] =3D 0; } - prev =3D (int *)vs->tight.gradient.buffer; + prev =3D (int *)vs->tight->gradient.buffer; for (x =3D 0; x < w; x++) { pix32 =3D *buf32++; for (c =3D 0; c < 3; c++) { @@ -615,7 +615,7 @@ tight_filter_gradient24(VncState *vs, uint8_t *buf, int= w, int h) int prediction; \ int x, y, c; \ \ - memset (vs->tight.gradient.buffer, 0, w * 3 * sizeof(int)); \ + memset(vs->tight->gradient.buffer, 0, w * 3 * sizeof(int)); \ \ endian =3D 0; /* FIXME */ \ \ @@ -631,7 +631,7 @@ tight_filter_gradient24(VncState *vs, uint8_t *buf, int= w, int h) upper[c] =3D 0; \ here[c] =3D 0; \ } \ - prev =3D (int *)vs->tight.gradient.buffer; \ + prev =3D (int *)vs->tight->gradient.buffer; = \ for (x =3D 0; x < w; x++) { \ pix =3D *buf; \ if (endian) { \ @@ -785,7 +785,7 @@ static void extend_solid_area(VncState *vs, int x, int = y, int w, int h, static int tight_init_stream(VncState *vs, int stream_id, int level, int strategy) { - z_streamp zstream =3D &vs->tight.stream[stream_id]; + z_streamp zstream =3D &vs->tight->stream[stream_id]; =20 if (zstream->opaque =3D=3D NULL) { int err; @@ -803,15 +803,15 @@ static int tight_init_stream(VncState *vs, int stream= _id, return -1; } =20 - vs->tight.levels[stream_id] =3D level; + vs->tight->levels[stream_id] =3D level; zstream->opaque =3D vs; } =20 - if (vs->tight.levels[stream_id] !=3D level) { + if (vs->tight->levels[stream_id] !=3D level) { if (deflateParams(zstream, level, strategy) !=3D Z_OK) { return -1; } - vs->tight.levels[stream_id] =3D level; + vs->tight->levels[stream_id] =3D level; } return 0; } @@ -839,11 +839,11 @@ static void tight_send_compact_size(VncState *vs, siz= e_t len) static int tight_compress_data(VncState *vs, int stream_id, size_t bytes, int level, int strategy) { - z_streamp zstream =3D &vs->tight.stream[stream_id]; + z_streamp zstream =3D &vs->tight->stream[stream_id]; int previous_out; =20 if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) { - vnc_write(vs, vs->tight.tight.buffer, vs->tight.tight.offset); + vnc_write(vs, vs->tight->tight.buffer, vs->tight->tight.offset); return bytes; } =20 @@ -852,13 +852,13 @@ static int tight_compress_data(VncState *vs, int stre= am_id, size_t bytes, } =20 /* reserve memory in output buffer */ - buffer_reserve(&vs->tight.zlib, bytes + 64); + buffer_reserve(&vs->tight->zlib, bytes + 64); =20 /* set pointers */ - zstream->next_in =3D vs->tight.tight.buffer; - zstream->avail_in =3D vs->tight.tight.offset; - zstream->next_out =3D vs->tight.zlib.buffer + vs->tight.zlib.offset; - zstream->avail_out =3D vs->tight.zlib.capacity - vs->tight.zlib.offset; + zstream->next_in =3D vs->tight->tight.buffer; + zstream->avail_in =3D vs->tight->tight.offset; + zstream->next_out =3D vs->tight->zlib.buffer + vs->tight->zlib.offset; + zstream->avail_out =3D vs->tight->zlib.capacity - vs->tight->zlib.offs= et; previous_out =3D zstream->avail_out; zstream->data_type =3D Z_BINARY; =20 @@ -868,14 +868,14 @@ static int tight_compress_data(VncState *vs, int stre= am_id, size_t bytes, return -1; } =20 - vs->tight.zlib.offset =3D vs->tight.zlib.capacity - zstream->avail_out; + vs->tight->zlib.offset =3D vs->tight->zlib.capacity - zstream->avail_o= ut; /* ...how much data has actually been produced by deflate() */ bytes =3D previous_out - zstream->avail_out; =20 tight_send_compact_size(vs, bytes); - vnc_write(vs, vs->tight.zlib.buffer, bytes); + vnc_write(vs, vs->tight->zlib.buffer, bytes); =20 - buffer_reset(&vs->tight.zlib); + buffer_reset(&vs->tight->zlib); =20 return bytes; } @@ -927,16 +927,17 @@ static int send_full_color_rect(VncState *vs, int x, = int y, int w, int h) =20 vnc_write_u8(vs, stream << 4); /* no flushing, no filter */ =20 - if (vs->tight.pixel24) { - tight_pack24(vs, vs->tight.tight.buffer, w * h, &vs->tight.tight.o= ffset); + if (vs->tight->pixel24) { + tight_pack24(vs, vs->tight->tight.buffer, w * h, + &vs->tight->tight.offset); bytes =3D 3; } else { bytes =3D vs->client_pf.bytes_per_pixel; } =20 bytes =3D tight_compress_data(vs, stream, w * h * bytes, - tight_conf[vs->tight.compression].raw_zlib= _level, - Z_DEFAULT_STRATEGY); + tight_conf[vs->tight->compression].raw_zlib_le= vel, + Z_DEFAULT_STRATEGY); =20 return (bytes >=3D 0); } @@ -947,14 +948,14 @@ static int send_solid_rect(VncState *vs) =20 vnc_write_u8(vs, VNC_TIGHT_FILL << 4); /* no flushing, no filter */ =20 - if (vs->tight.pixel24) { - tight_pack24(vs, vs->tight.tight.buffer, 1, &vs->tight.tight.offse= t); + if (vs->tight->pixel24) { + tight_pack24(vs, vs->tight->tight.buffer, 1, &vs->tight->tight.off= set); bytes =3D 3; } else { bytes =3D vs->client_pf.bytes_per_pixel; } =20 - vnc_write(vs, vs->tight.tight.buffer, bytes); + vnc_write(vs, vs->tight->tight.buffer, bytes); return 1; } =20 @@ -963,7 +964,7 @@ static int send_mono_rect(VncState *vs, int x, int y, { ssize_t bytes; int stream =3D 1; - int level =3D tight_conf[vs->tight.compression].mono_zlib_level; + int level =3D tight_conf[vs->tight->compression].mono_zlib_level; =20 #ifdef CONFIG_VNC_PNG if (tight_can_send_png_rect(vs, w, h)) { @@ -991,26 +992,26 @@ static int send_mono_rect(VncState *vs, int x, int y, uint32_t buf[2] =3D {bg, fg}; size_t ret =3D sizeof (buf); =20 - if (vs->tight.pixel24) { + if (vs->tight->pixel24) { tight_pack24(vs, (unsigned char*)buf, 2, &ret); } vnc_write(vs, buf, ret); =20 - tight_encode_mono_rect32(vs->tight.tight.buffer, w, h, bg, fg); + tight_encode_mono_rect32(vs->tight->tight.buffer, w, h, bg, fg); break; } case 2: vnc_write(vs, &bg, 2); vnc_write(vs, &fg, 2); - tight_encode_mono_rect16(vs->tight.tight.buffer, w, h, bg, fg); + tight_encode_mono_rect16(vs->tight->tight.buffer, w, h, bg, fg); break; default: vnc_write_u8(vs, bg); vnc_write_u8(vs, fg); - tight_encode_mono_rect8(vs->tight.tight.buffer, w, h, bg, fg); + tight_encode_mono_rect8(vs->tight->tight.buffer, w, h, bg, fg); break; } - vs->tight.tight.offset =3D bytes; + vs->tight->tight.offset =3D bytes; =20 bytes =3D tight_compress_data(vs, stream, bytes, level, Z_DEFAULT_STRA= TEGY); return (bytes >=3D 0); @@ -1040,7 +1041,7 @@ static void write_palette(int idx, uint32_t color, vo= id *opaque) static bool send_gradient_rect(VncState *vs, int x, int y, int w, int h) { int stream =3D 3; - int level =3D tight_conf[vs->tight.compression].gradient_zlib_level; + int level =3D tight_conf[vs->tight->compression].gradient_zlib_level; ssize_t bytes; =20 if (vs->client_pf.bytes_per_pixel =3D=3D 1) { @@ -1050,23 +1051,23 @@ static bool send_gradient_rect(VncState *vs, int x,= int y, int w, int h) vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4); vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT); =20 - buffer_reserve(&vs->tight.gradient, w * 3 * sizeof (int)); + buffer_reserve(&vs->tight->gradient, w * 3 * sizeof(int)); =20 - if (vs->tight.pixel24) { - tight_filter_gradient24(vs, vs->tight.tight.buffer, w, h); + if (vs->tight->pixel24) { + tight_filter_gradient24(vs, vs->tight->tight.buffer, w, h); bytes =3D 3; } else if (vs->client_pf.bytes_per_pixel =3D=3D 4) { - tight_filter_gradient32(vs, (uint32_t *)vs->tight.tight.buffer, w,= h); + tight_filter_gradient32(vs, (uint32_t *)vs->tight->tight.buffer, w= , h); bytes =3D 4; } else { - tight_filter_gradient16(vs, (uint16_t *)vs->tight.tight.buffer, w,= h); + tight_filter_gradient16(vs, (uint16_t *)vs->tight->tight.buffer, w= , h); bytes =3D 2; } =20 - buffer_reset(&vs->tight.gradient); + buffer_reset(&vs->tight->gradient); =20 bytes =3D w * h * bytes; - vs->tight.tight.offset =3D bytes; + vs->tight->tight.offset =3D bytes; =20 bytes =3D tight_compress_data(vs, stream, bytes, level, Z_FILTERED); @@ -1077,7 +1078,7 @@ static int send_palette_rect(VncState *vs, int x, int= y, int w, int h, VncPalette *palette) { int stream =3D 2; - int level =3D tight_conf[vs->tight.compression].idx_zlib_level; + int level =3D tight_conf[vs->tight->compression].idx_zlib_level; int colors; ssize_t bytes; =20 @@ -1104,12 +1105,12 @@ static int send_palette_rect(VncState *vs, int x, i= nt y, palette_iter(palette, write_palette, &priv); vnc_write(vs, header, sizeof(header)); =20 - if (vs->tight.pixel24) { + if (vs->tight->pixel24) { tight_pack24(vs, vs->output.buffer + old_offset, colors, &offs= et); vs->output.offset =3D old_offset + offset; } =20 - tight_encode_indexed_rect32(vs->tight.tight.buffer, w * h, palette= ); + tight_encode_indexed_rect32(vs->tight->tight.buffer, w * h, palett= e); break; } case 2: @@ -1119,7 +1120,7 @@ static int send_palette_rect(VncState *vs, int x, int= y, =20 palette_iter(palette, write_palette, &priv); vnc_write(vs, header, sizeof(header)); - tight_encode_indexed_rect16(vs->tight.tight.buffer, w * h, palette= ); + tight_encode_indexed_rect16(vs->tight->tight.buffer, w * h, palett= e); break; } default: @@ -1127,7 +1128,7 @@ static int send_palette_rect(VncState *vs, int x, int= y, break; } bytes =3D w * h; - vs->tight.tight.offset =3D bytes; + vs->tight->tight.offset =3D bytes; =20 bytes =3D tight_compress_data(vs, stream, bytes, level, Z_DEFAULT_STRATEGY); @@ -1146,7 +1147,7 @@ static int send_palette_rect(VncState *vs, int x, int= y, static void jpeg_init_destination(j_compress_ptr cinfo) { VncState *vs =3D cinfo->client_data; - Buffer *buffer =3D &vs->tight.jpeg; + Buffer *buffer =3D &vs->tight->jpeg; =20 cinfo->dest->next_output_byte =3D (JOCTET *)buffer->buffer + buffer->o= ffset; cinfo->dest->free_in_buffer =3D (size_t)(buffer->capacity - buffer->of= fset); @@ -1156,7 +1157,7 @@ static void jpeg_init_destination(j_compress_ptr cinf= o) static boolean jpeg_empty_output_buffer(j_compress_ptr cinfo) { VncState *vs =3D cinfo->client_data; - Buffer *buffer =3D &vs->tight.jpeg; + Buffer *buffer =3D &vs->tight->jpeg; =20 buffer->offset =3D buffer->capacity; buffer_reserve(buffer, 2048); @@ -1168,7 +1169,7 @@ static boolean jpeg_empty_output_buffer(j_compress_pt= r cinfo) static void jpeg_term_destination(j_compress_ptr cinfo) { VncState *vs =3D cinfo->client_data; - Buffer *buffer =3D &vs->tight.jpeg; + Buffer *buffer =3D &vs->tight->jpeg; =20 buffer->offset =3D buffer->capacity - cinfo->dest->free_in_buffer; } @@ -1187,7 +1188,7 @@ static int send_jpeg_rect(VncState *vs, int x, int y,= int w, int h, int quality) return send_full_color_rect(vs, x, y, w, h); } =20 - buffer_reserve(&vs->tight.jpeg, 2048); + buffer_reserve(&vs->tight->jpeg, 2048); =20 cinfo.err =3D jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); @@ -1222,9 +1223,9 @@ static int send_jpeg_rect(VncState *vs, int x, int y,= int w, int h, int quality) =20 vnc_write_u8(vs, VNC_TIGHT_JPEG << 4); =20 - tight_send_compact_size(vs, vs->tight.jpeg.offset); - vnc_write(vs, vs->tight.jpeg.buffer, vs->tight.jpeg.offset); - buffer_reset(&vs->tight.jpeg); + tight_send_compact_size(vs, vs->tight->jpeg.offset); + vnc_write(vs, vs->tight->jpeg.buffer, vs->tight->jpeg.offset); + buffer_reset(&vs->tight->jpeg); =20 return 1; } @@ -1240,7 +1241,7 @@ static void write_png_palette(int idx, uint32_t pix, = void *opaque) VncState *vs =3D priv->vs; png_colorp color =3D &priv->png_palette[idx]; =20 - if (vs->tight.pixel24) + if (vs->tight->pixel24) { color->red =3D (pix >> vs->client_pf.rshift) & vs->client_pf.rmax; color->green =3D (pix >> vs->client_pf.gshift) & vs->client_pf.gma= x; @@ -1267,10 +1268,10 @@ static void png_write_data(png_structp png_ptr, png= _bytep data, { VncState *vs =3D png_get_io_ptr(png_ptr); =20 - buffer_reserve(&vs->tight.png, vs->tight.png.offset + length); - memcpy(vs->tight.png.buffer + vs->tight.png.offset, data, length); + buffer_reserve(&vs->tight->png, vs->tight->png.offset + length); + memcpy(vs->tight->png.buffer + vs->tight->png.offset, data, length); =20 - vs->tight.png.offset +=3D length; + vs->tight->png.offset +=3D length; } =20 static void png_flush_data(png_structp png_ptr) @@ -1295,8 +1296,8 @@ static int send_png_rect(VncState *vs, int x, int y, = int w, int h, png_infop info_ptr; png_colorp png_palette =3D NULL; pixman_image_t *linebuf; - int level =3D tight_png_conf[vs->tight.compression].png_zlib_level; - int filters =3D tight_png_conf[vs->tight.compression].png_filters; + int level =3D tight_png_conf[vs->tight->compression].png_zlib_level; + int filters =3D tight_png_conf[vs->tight->compression].png_filters; uint8_t *buf; int dy; =20 @@ -1340,21 +1341,23 @@ static int send_png_rect(VncState *vs, int x, int y= , int w, int h, png_set_PLTE(png_ptr, info_ptr, png_palette, palette_size(palette)= ); =20 if (vs->client_pf.bytes_per_pixel =3D=3D 4) { - tight_encode_indexed_rect32(vs->tight.tight.buffer, w * h, pal= ette); + tight_encode_indexed_rect32(vs->tight->tight.buffer, w * h, + palette); } else { - tight_encode_indexed_rect16(vs->tight.tight.buffer, w * h, pal= ette); + tight_encode_indexed_rect16(vs->tight->tight.buffer, w * h, + palette); } } =20 png_write_info(png_ptr, info_ptr); =20 - buffer_reserve(&vs->tight.png, 2048); + buffer_reserve(&vs->tight->png, 2048); linebuf =3D qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, w); buf =3D (uint8_t *)pixman_image_get_data(linebuf); for (dy =3D 0; dy < h; dy++) { if (color_type =3D=3D PNG_COLOR_TYPE_PALETTE) { - memcpy(buf, vs->tight.tight.buffer + (dy * w), w); + memcpy(buf, vs->tight->tight.buffer + (dy * w), w); } else { qemu_pixman_linebuf_fill(linebuf, vs->vd->server, w, x, y + dy= ); } @@ -1372,27 +1375,27 @@ static int send_png_rect(VncState *vs, int x, int y= , int w, int h, =20 vnc_write_u8(vs, VNC_TIGHT_PNG << 4); =20 - tight_send_compact_size(vs, vs->tight.png.offset); - vnc_write(vs, vs->tight.png.buffer, vs->tight.png.offset); - buffer_reset(&vs->tight.png); + tight_send_compact_size(vs, vs->tight->png.offset); + vnc_write(vs, vs->tight->png.buffer, vs->tight->png.offset); + buffer_reset(&vs->tight->png); return 1; } #endif /* CONFIG_VNC_PNG */ =20 static void vnc_tight_start(VncState *vs) { - buffer_reset(&vs->tight.tight); + buffer_reset(&vs->tight->tight); =20 // make the output buffer be the zlib buffer, so we can compress it la= ter - vs->tight.tmp =3D vs->output; - vs->output =3D vs->tight.tight; + vs->tight->tmp =3D vs->output; + vs->output =3D vs->tight->tight; } =20 static void vnc_tight_stop(VncState *vs) { // switch back to normal output/zlib buffers - vs->tight.tight =3D vs->output; - vs->output =3D vs->tight.tmp; + vs->tight->tight =3D vs->output; + vs->output =3D vs->tight->tmp; } =20 static int send_sub_rect_nojpeg(VncState *vs, int x, int y, int w, int h, @@ -1426,9 +1429,9 @@ static int send_sub_rect_jpeg(VncState *vs, int x, in= t y, int w, int h, int ret; =20 if (colors =3D=3D 0) { - if (force || (tight_jpeg_conf[vs->tight.quality].jpeg_full && + if (force || (tight_jpeg_conf[vs->tight->quality].jpeg_full && tight_detect_smooth_image(vs, w, h))) { - int quality =3D tight_conf[vs->tight.quality].jpeg_quality; + int quality =3D tight_conf[vs->tight->quality].jpeg_quality; =20 ret =3D send_jpeg_rect(vs, x, y, w, h, quality); } else { @@ -1440,9 +1443,9 @@ static int send_sub_rect_jpeg(VncState *vs, int x, in= t y, int w, int h, ret =3D send_mono_rect(vs, x, y, w, h, bg, fg); } else if (colors <=3D 256) { if (force || (colors > 96 && - tight_jpeg_conf[vs->tight.quality].jpeg_idx && + tight_jpeg_conf[vs->tight->quality].jpeg_idx && tight_detect_smooth_image(vs, w, h))) { - int quality =3D tight_conf[vs->tight.quality].jpeg_quality; + int quality =3D tight_conf[vs->tight->quality].jpeg_quality; =20 ret =3D send_jpeg_rect(vs, x, y, w, h, quality); } else { @@ -1480,20 +1483,20 @@ static int send_sub_rect(VncState *vs, int x, int y= , int w, int h) qemu_thread_atexit_add(&vnc_tight_cleanup_notifier); } =20 - vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type); + vnc_framebuffer_update(vs, x, y, w, h, vs->tight->type); =20 vnc_tight_start(vs); vnc_raw_send_framebuffer_update(vs, x, y, w, h); vnc_tight_stop(vs); =20 #ifdef CONFIG_VNC_JPEG - if (!vs->vd->non_adaptive && vs->tight.quality !=3D (uint8_t)-1) { + if (!vs->vd->non_adaptive && vs->tight->quality !=3D (uint8_t)-1) { double freq =3D vnc_update_freq(vs, x, y, w, h); =20 - if (freq < tight_jpeg_conf[vs->tight.quality].jpeg_freq_min) { + if (freq < tight_jpeg_conf[vs->tight->quality].jpeg_freq_min) { allow_jpeg =3D false; } - if (freq >=3D tight_jpeg_conf[vs->tight.quality].jpeg_freq_thresho= ld) { + if (freq >=3D tight_jpeg_conf[vs->tight->quality].jpeg_freq_thresh= old) { force_jpeg =3D true; vnc_sent_lossy_rect(vs, x, y, w, h); } @@ -1503,7 +1506,7 @@ static int send_sub_rect(VncState *vs, int x, int y, = int w, int h) colors =3D tight_fill_palette(vs, x, y, w * h, &bg, &fg, color_count_p= alette); =20 #ifdef CONFIG_VNC_JPEG - if (allow_jpeg && vs->tight.quality !=3D (uint8_t)-1) { + if (allow_jpeg && vs->tight->quality !=3D (uint8_t)-1) { ret =3D send_sub_rect_jpeg(vs, x, y, w, h, bg, fg, colors, color_count_palette, force_jpeg); } else { @@ -1520,7 +1523,7 @@ static int send_sub_rect(VncState *vs, int x, int y, = int w, int h) =20 static int send_sub_rect_solid(VncState *vs, int x, int y, int w, int h) { - vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type); + vnc_framebuffer_update(vs, x, y, w, h, vs->tight->type); =20 vnc_tight_start(vs); vnc_raw_send_framebuffer_update(vs, x, y, w, h); @@ -1538,8 +1541,8 @@ static int send_rect_simple(VncState *vs, int x, int = y, int w, int h, int rw, rh; int n =3D 0; =20 - max_size =3D tight_conf[vs->tight.compression].max_rect_size; - max_width =3D tight_conf[vs->tight.compression].max_rect_width; + max_size =3D tight_conf[vs->tight->compression].max_rect_size; + max_width =3D tight_conf[vs->tight->compression].max_rect_width; =20 if (split && (w > max_width || w * h > max_size)) { max_sub_width =3D (w > max_width) ? max_width : w; @@ -1648,16 +1651,16 @@ static int tight_send_framebuffer_update(VncState *= vs, int x, int y, =20 if (vs->client_pf.bytes_per_pixel =3D=3D 4 && vs->client_pf.rmax =3D= =3D 0xFF && vs->client_pf.bmax =3D=3D 0xFF && vs->client_pf.gmax =3D=3D 0xFF) { - vs->tight.pixel24 =3D true; + vs->tight->pixel24 =3D true; } else { - vs->tight.pixel24 =3D false; + vs->tight->pixel24 =3D false; } =20 #ifdef CONFIG_VNC_JPEG - if (vs->tight.quality !=3D (uint8_t)-1) { + if (vs->tight->quality !=3D (uint8_t)-1) { double freq =3D vnc_update_freq(vs, x, y, w, h); =20 - if (freq > tight_jpeg_conf[vs->tight.quality].jpeg_freq_threshold)= { + if (freq > tight_jpeg_conf[vs->tight->quality].jpeg_freq_threshold= ) { return send_rect_simple(vs, x, y, w, h, false); } } @@ -1669,8 +1672,8 @@ static int tight_send_framebuffer_update(VncState *vs= , int x, int y, =20 /* Calculate maximum number of rows in one non-solid rectangle. */ =20 - max_rows =3D tight_conf[vs->tight.compression].max_rect_size; - max_rows /=3D MIN(tight_conf[vs->tight.compression].max_rect_width, w); + max_rows =3D tight_conf[vs->tight->compression].max_rect_size; + max_rows /=3D MIN(tight_conf[vs->tight->compression].max_rect_width, w= ); =20 return find_large_solid_color_rect(vs, x, y, w, h, max_rows); } @@ -1678,33 +1681,33 @@ static int tight_send_framebuffer_update(VncState *= vs, int x, int y, int vnc_tight_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { - vs->tight.type =3D VNC_ENCODING_TIGHT; + vs->tight->type =3D VNC_ENCODING_TIGHT; return tight_send_framebuffer_update(vs, x, y, w, h); } =20 int vnc_tight_png_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { - vs->tight.type =3D VNC_ENCODING_TIGHT_PNG; + vs->tight->type =3D VNC_ENCODING_TIGHT_PNG; return tight_send_framebuffer_update(vs, x, y, w, h); } =20 void vnc_tight_clear(VncState *vs) { int i; - for (i=3D0; itight.stream); i++) { - if (vs->tight.stream[i].opaque) { - deflateEnd(&vs->tight.stream[i]); + for (i =3D 0; i < ARRAY_SIZE(vs->tight->stream); i++) { + if (vs->tight->stream[i].opaque) { + deflateEnd(&vs->tight->stream[i]); } } =20 - buffer_free(&vs->tight.tight); - buffer_free(&vs->tight.zlib); - buffer_free(&vs->tight.gradient); + buffer_free(&vs->tight->tight); + buffer_free(&vs->tight->zlib); + buffer_free(&vs->tight->gradient); #ifdef CONFIG_VNC_JPEG - buffer_free(&vs->tight.jpeg); + buffer_free(&vs->tight->jpeg); #endif #ifdef CONFIG_VNC_PNG - buffer_free(&vs->tight.png); + buffer_free(&vs->tight->png); #endif } diff --git a/ui/vnc-enc-zlib.c b/ui/vnc-enc-zlib.c index 33e9df2f6a..900ae5b30f 100644 --- a/ui/vnc-enc-zlib.c +++ b/ui/vnc-enc-zlib.c @@ -76,7 +76,8 @@ static int vnc_zlib_stop(VncState *vs) zstream->zalloc =3D vnc_zlib_zalloc; zstream->zfree =3D vnc_zlib_zfree; =20 - err =3D deflateInit2(zstream, vs->tight.compression, Z_DEFLATED, M= AX_WBITS, + err =3D deflateInit2(zstream, vs->tight->compression, Z_DEFLATED, + MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); =20 if (err !=3D Z_OK) { @@ -84,16 +85,16 @@ static int vnc_zlib_stop(VncState *vs) return -1; } =20 - vs->zlib.level =3D vs->tight.compression; + vs->zlib.level =3D vs->tight->compression; zstream->opaque =3D vs; } =20 - if (vs->tight.compression !=3D vs->zlib.level) { - if (deflateParams(zstream, vs->tight.compression, + if (vs->tight->compression !=3D vs->zlib.level) { + if (deflateParams(zstream, vs->tight->compression, Z_DEFAULT_STRATEGY) !=3D Z_OK) { return -1; } - vs->zlib.level =3D vs->tight.compression; + vs->zlib.level =3D vs->tight->compression; } =20 // reserve memory in output buffer diff --git a/ui/vnc-enc-zrle.c b/ui/vnc-enc-zrle.c index 7493a84723..17fd28a2e2 100644 --- a/ui/vnc-enc-zrle.c +++ b/ui/vnc-enc-zrle.c @@ -37,18 +37,18 @@ static const int bits_per_packed_pixel[] =3D { =20 static void vnc_zrle_start(VncState *vs) { - buffer_reset(&vs->zrle.zrle); + buffer_reset(&vs->zrle->zrle); =20 /* make the output buffer be the zlib buffer, so we can compress it la= ter */ - vs->zrle.tmp =3D vs->output; - vs->output =3D vs->zrle.zrle; + vs->zrle->tmp =3D vs->output; + vs->output =3D vs->zrle->zrle; } =20 static void vnc_zrle_stop(VncState *vs) { /* switch back to normal output/zlib buffers */ - vs->zrle.zrle =3D vs->output; - vs->output =3D vs->zrle.tmp; + vs->zrle->zrle =3D vs->output; + vs->output =3D vs->zrle->tmp; } =20 static void *zrle_convert_fb(VncState *vs, int x, int y, int w, int h, @@ -56,24 +56,24 @@ static void *zrle_convert_fb(VncState *vs, int x, int y= , int w, int h, { Buffer tmp; =20 - buffer_reset(&vs->zrle.fb); - buffer_reserve(&vs->zrle.fb, w * h * bpp + bpp); + buffer_reset(&vs->zrle->fb); + buffer_reserve(&vs->zrle->fb, w * h * bpp + bpp); =20 tmp =3D vs->output; - vs->output =3D vs->zrle.fb; + vs->output =3D vs->zrle->fb; =20 vnc_raw_send_framebuffer_update(vs, x, y, w, h); =20 - vs->zrle.fb =3D vs->output; + vs->zrle->fb =3D vs->output; vs->output =3D tmp; - return vs->zrle.fb.buffer; + return vs->zrle->fb.buffer; } =20 static int zrle_compress_data(VncState *vs, int level) { - z_streamp zstream =3D &vs->zrle.stream; + z_streamp zstream =3D &vs->zrle->stream; =20 - buffer_reset(&vs->zrle.zlib); + buffer_reset(&vs->zrle->zlib); =20 if (zstream->opaque !=3D vs) { int err; @@ -93,13 +93,13 @@ static int zrle_compress_data(VncState *vs, int level) } =20 /* reserve memory in output buffer */ - buffer_reserve(&vs->zrle.zlib, vs->zrle.zrle.offset + 64); + buffer_reserve(&vs->zrle->zlib, vs->zrle->zrle.offset + 64); =20 /* set pointers */ - zstream->next_in =3D vs->zrle.zrle.buffer; - zstream->avail_in =3D vs->zrle.zrle.offset; - zstream->next_out =3D vs->zrle.zlib.buffer + vs->zrle.zlib.offset; - zstream->avail_out =3D vs->zrle.zlib.capacity - vs->zrle.zlib.offset; + zstream->next_in =3D vs->zrle->zrle.buffer; + zstream->avail_in =3D vs->zrle->zrle.offset; + zstream->next_out =3D vs->zrle->zlib.buffer + vs->zrle->zlib.offset; + zstream->avail_out =3D vs->zrle->zlib.capacity - vs->zrle->zlib.offset; zstream->data_type =3D Z_BINARY; =20 /* start encoding */ @@ -108,8 +108,8 @@ static int zrle_compress_data(VncState *vs, int level) return -1; } =20 - vs->zrle.zlib.offset =3D vs->zrle.zlib.capacity - zstream->avail_out; - return vs->zrle.zlib.offset; + vs->zrle->zlib.offset =3D vs->zrle->zlib.capacity - zstream->avail_out; + return vs->zrle->zlib.offset; } =20 /* Try to work out whether to use RLE and/or a palette. We do this by @@ -259,14 +259,14 @@ static int zrle_send_framebuffer_update(VncState *vs,= int x, int y, size_t bytes; int zywrle_level; =20 - if (vs->zrle.type =3D=3D VNC_ENCODING_ZYWRLE) { - if (!vs->vd->lossy || vs->tight.quality =3D=3D (uint8_t)-1 - || vs->tight.quality =3D=3D 9) { + if (vs->zrle->type =3D=3D VNC_ENCODING_ZYWRLE) { + if (!vs->vd->lossy || vs->tight->quality =3D=3D (uint8_t)-1 + || vs->tight->quality =3D=3D 9) { zywrle_level =3D 0; - vs->zrle.type =3D VNC_ENCODING_ZRLE; - } else if (vs->tight.quality < 3) { + vs->zrle->type =3D VNC_ENCODING_ZRLE; + } else if (vs->tight->quality < 3) { zywrle_level =3D 3; - } else if (vs->tight.quality < 6) { + } else if (vs->tight->quality < 6) { zywrle_level =3D 2; } else { zywrle_level =3D 1; @@ -337,30 +337,30 @@ static int zrle_send_framebuffer_update(VncState *vs,= int x, int y, =20 vnc_zrle_stop(vs); bytes =3D zrle_compress_data(vs, Z_DEFAULT_COMPRESSION); - vnc_framebuffer_update(vs, x, y, w, h, vs->zrle.type); + vnc_framebuffer_update(vs, x, y, w, h, vs->zrle->type); vnc_write_u32(vs, bytes); - vnc_write(vs, vs->zrle.zlib.buffer, vs->zrle.zlib.offset); + vnc_write(vs, vs->zrle->zlib.buffer, vs->zrle->zlib.offset); return 1; } =20 int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, in= t h) { - vs->zrle.type =3D VNC_ENCODING_ZRLE; + vs->zrle->type =3D VNC_ENCODING_ZRLE; return zrle_send_framebuffer_update(vs, x, y, w, h); } =20 int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, = int h) { - vs->zrle.type =3D VNC_ENCODING_ZYWRLE; + vs->zrle->type =3D VNC_ENCODING_ZYWRLE; return zrle_send_framebuffer_update(vs, x, y, w, h); } =20 void vnc_zrle_clear(VncState *vs) { - if (vs->zrle.stream.opaque) { - deflateEnd(&vs->zrle.stream); + if (vs->zrle->stream.opaque) { + deflateEnd(&vs->zrle->stream); } - buffer_free(&vs->zrle.zrle); - buffer_free(&vs->zrle.fb); - buffer_free(&vs->zrle.zlib); + buffer_free(&vs->zrle->zrle); + buffer_free(&vs->zrle->fb); + buffer_free(&vs->zrle->zlib); } diff --git a/ui/vnc-enc-zrle.inc.c b/ui/vnc-enc-zrle.inc.c index abf6b86e4e..c107d8affc 100644 --- a/ui/vnc-enc-zrle.inc.c +++ b/ui/vnc-enc-zrle.inc.c @@ -96,7 +96,7 @@ static void ZRLE_ENCODE(VncState *vs, int x, int y, int w= , int h, static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h, int zywrle_level) { - VncPalette *palette =3D &vs->zrle.palette; + VncPalette *palette =3D &vs->zrle->palette; =20 int runs =3D 0; int single_pixels =3D 0; diff --git a/ui/vnc.c b/ui/vnc.c index 649ce93cd2..0403b0b312 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1306,6 +1306,8 @@ void vnc_disconnect_finish(VncState *vs) object_unref(OBJECT(vs->sioc)); vs->sioc =3D NULL; vs->magic =3D 0; + g_free(vs->zrle); + g_free(vs->tight); g_free(vs); } =20 @@ -2057,8 +2059,8 @@ static void set_encodings(VncState *vs, int32_t *enco= dings, size_t n_encodings) =20 vs->features =3D 0; vs->vnc_encoding =3D 0; - vs->tight.compression =3D 9; - vs->tight.quality =3D -1; /* Lossless by default */ + vs->tight->compression =3D 9; + vs->tight->quality =3D -1; /* Lossless by default */ vs->absolute =3D -1; =20 /* @@ -2126,11 +2128,11 @@ static void set_encodings(VncState *vs, int32_t *en= codings, size_t n_encodings) vs->features |=3D VNC_FEATURE_LED_STATE_MASK; break; case VNC_ENCODING_COMPRESSLEVEL0 ... VNC_ENCODING_COMPRESSLEVEL0 += 9: - vs->tight.compression =3D (enc & 0x0F); + vs->tight->compression =3D (enc & 0x0F); break; case VNC_ENCODING_QUALITYLEVEL0 ... VNC_ENCODING_QUALITYLEVEL0 + 9: if (vs->vd->lossy) { - vs->tight.quality =3D (enc & 0x0F); + vs->tight->quality =3D (enc & 0x0F); } break; default: @@ -3033,6 +3035,8 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSoc= ket *sioc, int i; =20 trace_vnc_client_connect(vs, sioc); + vs->zrle =3D g_new0(VncZrle, 1); + vs->tight =3D g_new0(VncTight, 1); vs->magic =3D VNC_MAGIC; vs->sioc =3D sioc; object_ref(OBJECT(vs->sioc)); @@ -3044,19 +3048,19 @@ static void vnc_connect(VncDisplay *vd, QIOChannelS= ocket *sioc, buffer_init(&vs->output, "vnc-output/%p", sioc); buffer_init(&vs->jobs_buffer, "vnc-jobs_buffer/%p", sioc); =20 - buffer_init(&vs->tight.tight, "vnc-tight/%p", sioc); - buffer_init(&vs->tight.zlib, "vnc-tight-zlib/%p", sioc); - buffer_init(&vs->tight.gradient, "vnc-tight-gradient/%p", sioc); + buffer_init(&vs->tight->tight, "vnc-tight/%p", sioc); + buffer_init(&vs->tight->zlib, "vnc-tight-zlib/%p", sioc); + buffer_init(&vs->tight->gradient, "vnc-tight-gradient/%p", sioc); #ifdef CONFIG_VNC_JPEG - buffer_init(&vs->tight.jpeg, "vnc-tight-jpeg/%p", sioc); + buffer_init(&vs->tight->jpeg, "vnc-tight-jpeg/%p", sioc); #endif #ifdef CONFIG_VNC_PNG - buffer_init(&vs->tight.png, "vnc-tight-png/%p", sioc); + buffer_init(&vs->tight->png, "vnc-tight-png/%p", sioc); #endif buffer_init(&vs->zlib.zlib, "vnc-zlib/%p", sioc); - buffer_init(&vs->zrle.zrle, "vnc-zrle/%p", sioc); - buffer_init(&vs->zrle.fb, "vnc-zrle-fb/%p", sioc); - buffer_init(&vs->zrle.zlib, "vnc-zrle-zlib/%p", sioc); + buffer_init(&vs->zrle->zrle, "vnc-zrle/%p", sioc); + buffer_init(&vs->zrle->fb, "vnc-zrle-fb/%p", sioc); + buffer_init(&vs->zrle->zlib, "vnc-zrle-zlib/%p", sioc); =20 if (skipauth) { vs->auth =3D VNC_AUTH_NONE; diff --git a/ui/vnc.h b/ui/vnc.h index 8643860967..fea79c2fc9 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -338,10 +338,10 @@ struct VncState /* Encoding specific, if you add something here, don't forget to * update vnc_async_encoding_start() */ - VncTight tight; + VncTight *tight; VncZlib zlib; VncHextile hextile; - VncZrle zrle; + VncZrle *zrle; VncZywrle zywrle; =20 Notifier mouse_mode_notifier; --=20 2.17.1