]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
monitor: Fix memory leak with readline completion
authorStefan Weil <sw@weilnetz.de>
Mon, 14 May 2012 19:47:20 +0000 (21:47 +0200)
committerLuiz Capitulino <lcapitulino@redhat.com>
Fri, 15 Jun 2012 13:41:05 +0000 (10:41 -0300)
Each string which is shown during readline completion in the QEMU monitor
is allocated dynamically but currently never deallocated.

Add the missing loop which calls g_free for the allocated strings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
readline.c

index a6c0039ad2c23bae5817f7ac37f1b1b73487800f..540cd8a025d145dd3fe28e538bd79f9198e9c5fc 100644 (file)
@@ -337,6 +337,9 @@ static void readline_completion(ReadLineState *rs)
         }
         readline_show_prompt(rs);
     }
+    for (i = 0; i < rs->nb_completions; i++) {
+        g_free(rs->completions[i]);
+    }
 }
 
 /* return true if command handled */