diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2018-05-07 12:22:54 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-05-15 10:36:55 +0200 |
commit | f31f9c1080d8907c95f1501c6abab038eceb5490 (patch) | |
tree | 9f16e082465c821b35d560f1e28988dfc3778dc3 /ui/vnc-jobs.c | |
parent | 4f4cb8282df82d43ba6b3c9045a3ac6fc4c4ef09 (diff) |
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
Diffstat (limited to 'ui/vnc-jobs.c')
-rw-r--r-- | ui/vnc-jobs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index 868dddef4b..b0b15d42a8 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -82,6 +82,7 @@ VncJob *vnc_job_new(VncState *vs) { 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 @@ static int vnc_worker_thread_loop(VncJobQueue *queue) /* 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 @@ static int vnc_worker_thread_loop(VncJobQueue *queue) /* 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 @@ disconnected: vnc_unlock_queue(queue); qemu_cond_broadcast(&queue->cond); g_free(job); + vs.magic = 0; return 0; } |