From 1a729dc0129052a028eae4582a6d6d10564d13c4 Mon Sep 17 00:00:00 2001
From: Pierre Ossman <ossman@cendio.se>
Date: Tue, 18 Jan 2022 13:38:41 +0100
Subject: [PATCH] Fix handling of VMware cursors

This is a regression from ad0f061. If a VMware cursor rect was split up
over multiple read()s then the stream would become corrupted as we set
the restore point at the wrong place.
---
 common/rfb/CMsgReader.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: pkg-tigervnc/common/rfb/CMsgReader.cxx
===================================================================
--- pkg-tigervnc.orig/common/rfb/CMsgReader.cxx
+++ pkg-tigervnc/common/rfb/CMsgReader.cxx
@@ -632,11 +632,11 @@ bool CMsgReader::readSetVMwareCursor(int
   if (!is->hasData(1 + 1))
     return false;
 
+  is->setRestorePoint();
+
   type = is->readU8();
   is->skip(1);
 
-  is->setRestorePoint();
-
   if (type == 0) {
     int len = width * height * (handler->server.pf().bpp/8);
     rdr::U8Array andMask(len);
