OSDN Git Service

monitor: Fix memory leak with readline completion
authorStefan Weil <sw@weilnetz.de>
Mon, 14 May 2012 09:47:20 +0000 (09:47 +0000)
committerStefan Weil <sw@weilnetz.de>
Mon, 11 Jun 2012 20:20:00 +0000 (22:20 +0200)
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>
readline.c

index a6c0039..540cd8a 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 */