[PATCH v3 0/2] ui/vnc: Do not copy z_stream

Akihiko Odaki posted 2 patches 5 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250603-zlib-v3-0-20b857bd8d05@rsg.ci.i.u-tokyo.ac.jp
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/vnc.h              |  49 ++++--
ui/vnc-enc-tight.c    | 456 ++++++++++++++++++++++++++------------------------
ui/vnc-enc-zlib.c     |  47 +++---
ui/vnc-enc-zrle.c     | 122 +++++++-------
ui/vnc-jobs.c         |  13 +-
ui/vnc.c              |  83 ++++-----
ui/vnc-enc-zrle.c.inc |  20 +--
7 files changed, 407 insertions(+), 383 deletions(-)
[PATCH v3 0/2] ui/vnc: Do not copy z_stream
Posted by Akihiko Odaki 5 months, 2 weeks ago
vnc_worker_thread_loop() copies z_stream stored in its local VncState to
the persistent VncState, and the copied one is freed with deflateEnd()
later. However, deflateEnd() refuses to operate with a copied z_stream
and returns Z_STREAM_ERROR, leaking the allocated memory.

Avoid copying the zlib state to fix the memory leak.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
Changes in v3:
- Rebased.
- Reordered the patches.
- Removed the extra allocation of VncWorker.
- Removed the worker field from VncState.
- Dropped the Reviewed-by tags.
- Link to v2: https://lore.kernel.org/qemu-devel/20250531-zlib-v2-0-b75c4b4769e1@rsg.ci.i.u-tokyo.ac.jp

Changes in v2:
- Rebased.
- Link to v1: https://lore.kernel.org/qemu-devel/20250417-zlib-v1-0-34fad73b843b@daynix.com

---
Akihiko Odaki (2):
      ui/vnc: Do not copy z_stream
      ui/vnc: Introduce the VncWorker type

 ui/vnc.h              |  49 ++++--
 ui/vnc-enc-tight.c    | 456 ++++++++++++++++++++++++++------------------------
 ui/vnc-enc-zlib.c     |  47 +++---
 ui/vnc-enc-zrle.c     | 122 +++++++-------
 ui/vnc-jobs.c         |  13 +-
 ui/vnc.c              |  83 ++++-----
 ui/vnc-enc-zrle.c.inc |  20 +--
 7 files changed, 407 insertions(+), 383 deletions(-)
---
base-commit: 6322b753f798337835e205b6d805356bea582c86
change-id: 20250417-zlib-ce3034f8bc3c

Best regards,
-- 
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>