diff mbox series

vnc: move assert in vnc_worker_thread_loop

Message ID 20230609092306.19836-1-abelova@astralinux.ru
State New
Headers show
Series vnc: move assert in vnc_worker_thread_loop | expand

Commit Message

Anastasia Belova June 9, 2023, 9:23 a.m. UTC
job may be NULL if queue->exit is true. Check
it before dereference job.

Fixes: f31f9c1080 ("vnc: add magic cookie to VncState")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 ui/vnc-jobs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Tokarev June 9, 2023, 8:20 p.m. UTC | #1
09.06.2023 12:23, Anastasia Belova wrote:
> job may be NULL if queue->exit is true. Check
> it before dereference job.
> 
> Fixes: f31f9c1080 ("vnc: add magic cookie to VncState")
> Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
> ---
>   ui/vnc-jobs.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
> index 886f9bf611..fcca7ec632 100644
> --- a/ui/vnc-jobs.c
> +++ b/ui/vnc-jobs.c
> @@ -250,12 +250,13 @@ 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;
>       }
>   
> +    assert(job->vs->magic == VNC_MAGIC);
> +

This is a good one, I like it :)

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

It can be applied though -trivial queue.

Thank you!

/mjt
diff mbox series

Patch

diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index 886f9bf611..fcca7ec632 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -250,12 +250,13 @@  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;
     }
 
+    assert(job->vs->magic == VNC_MAGIC);
+
     vnc_lock_output(job->vs);
     if (job->vs->ioc == NULL || job->vs->abort == true) {
         vnc_unlock_output(job->vs);