diff mbox series

vnc: fix memleak of the "vnc-worker-output" name

Message ID 20180807221830.3844-1-peter@lekensteyn.nl (mailing list archive)
State New, archived
Headers show
Series vnc: fix memleak of the "vnc-worker-output" name | expand

Commit Message

Peter Wu Aug. 7, 2018, 10:18 p.m. UTC
Fixes repeated memory leaks of 18 bytes when using VNC:

    Direct leak of 831024 byte(s) in 46168 object(s) allocated from:
        ...
        #4 0x7f6d2f919bdd in g_strdup_vprintf glib/gstrfuncs.c:514
        #5 0x56085cdcf660 in buffer_init util/buffer.c:59
        #6 0x56085ca6a7ec in vnc_async_encoding_start ui/vnc-jobs.c:177
        #7 0x56085ca6b815 in vnc_worker_thread_loop ui/vnc-jobs.c:240

Fixes: 543b95801f98 ("vnc: attach names to buffers")
Cc: Gerd Hoffmann <kraxel@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
---
 ui/vnc-jobs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Marc-André Lureau Aug. 7, 2018, 10:53 p.m. UTC | #1
Hi

On Wed, Aug 8, 2018 at 12:18 AM, Peter Wu <peter@lekensteyn.nl> wrote:
> Fixes repeated memory leaks of 18 bytes when using VNC:
>
>     Direct leak of 831024 byte(s) in 46168 object(s) allocated from:
>         ...
>         #4 0x7f6d2f919bdd in g_strdup_vprintf glib/gstrfuncs.c:514
>         #5 0x56085cdcf660 in buffer_init util/buffer.c:59
>         #6 0x56085ca6a7ec in vnc_async_encoding_start ui/vnc-jobs.c:177
>         #7 0x56085ca6b815 in vnc_worker_thread_loop ui/vnc-jobs.c:240
>
> Fixes: 543b95801f98 ("vnc: attach names to buffers")
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> CC: qemu-stable@nongnu.org
> Signed-off-by: Peter Wu <peter@lekensteyn.nl>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  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 b0b15d42a8..929391f85d 100644
> --- a/ui/vnc-jobs.c
> +++ b/ui/vnc-jobs.c
> @@ -193,6 +193,7 @@ static void vnc_async_encoding_start(VncState *orig, VncState *local)
>
>  static void vnc_async_encoding_end(VncState *orig, VncState *local)
>  {
> +    buffer_free(&local->output);
>      orig->tight = local->tight;
>      orig->zlib = local->zlib;
>      orig->hextile = local->hextile;
> @@ -278,7 +279,7 @@ static int vnc_worker_thread_loop(VncJobQueue *queue)
>          /* Copy persistent encoding data */
>          vnc_async_encoding_end(job->vs, &vs);
>
> -       qemu_bh_schedule(job->vs->bh);
> +        qemu_bh_schedule(job->vs->bh);

just fixing a tab, not a big deal, but preferably not in the same patch

>      }  else {
>          buffer_reset(&vs.output);
>          /* Copy persistent encoding data */
> --
> 2.18.0
>
>
Gerd Hoffmann Aug. 21, 2018, 5:39 a.m. UTC | #2
On Wed, Aug 08, 2018 at 12:18:30AM +0200, Peter Wu wrote:
> Fixes repeated memory leaks of 18 bytes when using VNC:
> 
>     Direct leak of 831024 byte(s) in 46168 object(s) allocated from:
>         ...
>         #4 0x7f6d2f919bdd in g_strdup_vprintf glib/gstrfuncs.c:514
>         #5 0x56085cdcf660 in buffer_init util/buffer.c:59
>         #6 0x56085ca6a7ec in vnc_async_encoding_start ui/vnc-jobs.c:177
>         #7 0x56085ca6b815 in vnc_worker_thread_loop ui/vnc-jobs.c:240
> 
> Fixes: 543b95801f98 ("vnc: attach names to buffers")
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> CC: qemu-stable@nongnu.org
> Signed-off-by: Peter Wu <peter@lekensteyn.nl>

Added to ui queue.

thanks,
  Gerd
diff mbox series

Patch

diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index b0b15d42a8..929391f85d 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -193,6 +193,7 @@  static void vnc_async_encoding_start(VncState *orig, VncState *local)
 
 static void vnc_async_encoding_end(VncState *orig, VncState *local)
 {
+    buffer_free(&local->output);
     orig->tight = local->tight;
     orig->zlib = local->zlib;
     orig->hextile = local->hextile;
@@ -278,7 +279,7 @@  static int vnc_worker_thread_loop(VncJobQueue *queue)
         /* Copy persistent encoding data */
         vnc_async_encoding_end(job->vs, &vs);
 
-	qemu_bh_schedule(job->vs->bh);
+        qemu_bh_schedule(job->vs->bh);
     }  else {
         buffer_reset(&vs.output);
         /* Copy persistent encoding data */