vnc: add magic cookie to VncState
Set magic cookie on initialization. Clear on cleanup. Sprinkle a bunch
of assert()s checking the cookie, to verify the pointer is valid.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20180507102254.12107-1-kraxel@redhat.com
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index 868ddde..b0b15d4 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -82,6 +82,7 @@
{
VncJob *job = g_new0(VncJob, 1);
+ assert(vs->magic == VNC_MAGIC);
job->vs = vs;
vnc_lock_queue(queue);
QLIST_INIT(&job->rectangles);
@@ -214,6 +215,7 @@
/* Here job can only be NULL if queue->exit is true */
job = QTAILQ_FIRST(&queue->jobs);
vnc_unlock_queue(queue);
+ assert(job->vs->magic == VNC_MAGIC);
if (queue->exit) {
return -1;
@@ -236,6 +238,7 @@
/* Make a local copy of vs and switch output buffers */
vnc_async_encoding_start(job->vs, &vs);
+ vs.magic = VNC_MAGIC;
/* Start sending rectangles */
n_rectangles = 0;
@@ -289,6 +292,7 @@
vnc_unlock_queue(queue);
qemu_cond_broadcast(&queue->cond);
g_free(job);
+ vs.magic = 0;
return 0;
}