Skip to contentSkip to conversation

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

PATCH In review Peter Wu 3 participants 3 messages Aug 7, 2018 – Aug 21, 2018

lore
Share & tools
lore

Peter Wu

author
#0 lore raw

PATCH 1/1 vnc: fix memleak of the "vnc-worker-output" name

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 <[email protected]>
---
 ui/vnc-jobs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
ui/vnc-jobs.c +2 -1
index b0b15d42a8..929391f85d 100644
@@ -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 */
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw

Hi

Quoted 9 lines · Peter Wu

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
Quoted 4 lines
Fixes 543b95801f98 ("vnc: attach names to buffers")
Cc Gerd Hoffmann <[email protected]>
Quoted 17 lines
---
 ui/vnc-jobs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
ui/vnc-jobs.c +1 -0
index b0b15d42a8..929391f85d 100644
@@ -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;

ui/vnc-jobs.c static int vnc_worker_thread_loop(VncJobQueue *queue) · line 282

Quoted 5 lines
ui/vnc-jobs.c +1 -1
@@ -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

Quoted 7 lines
ui/vnc-jobs.c +0 -1
     }  else {
         buffer_reset(&vs.output);
         /* Copy persistent encoding data */
--

2.18.0

Signature · 1 line
Marc-André Lureau
#2 lore raw
In reply to Peter Wu
Quoted 9 lines · Peter Wu

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
Quoted 4 lines
Fixes 543b95801f98 ("vnc: attach names to buffers")
Cc Gerd Hoffmann <[email protected]>

Added to ui queue.

thanks,
Gerd