[1.1] monitor: Fix memory leak with readline completion
diff mbox

Message ID 1337024840-28273-1-git-send-email-sw@weilnetz.de
State Accepted
Headers show

Commit Message

Stefan Weil May 14, 2012, 7:47 p.m. UTC
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>
---
 readline.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Stefan Weil May 22, 2012, 8:24 p.m. UTC | #1
Am 14.05.2012 21:47, schrieb Stefan Weil:
> 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>
> ---
>   readline.c |    3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/readline.c b/readline.c
> index a6c0039..646b6e8 100644
> --- a/readline.c
> +++ b/readline.c
> @@ -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 */
>    

Ping?

This patch is for QEMU 1.1, but was not committed up to now.

Regards,
Stefan Weil
Stefan Weil June 9, 2012, 9:36 p.m. UTC | #2
Am 22.05.2012 22:24, schrieb Stefan Weil:
> Am 14.05.2012 21:47, schrieb Stefan Weil:
>> 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>
>> ---
>>   readline.c |    3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/readline.c b/readline.c
>> index a6c0039..646b6e8 100644
>> --- a/readline.c
>> +++ b/readline.c
>> @@ -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 */
>
> Ping?
>
> This patch is for QEMU 1.1, but was not committed up to now.
>
> Regards,
> Stefan Weil
>


Ping^2? Should I send a pull request?
The patch is available at http://patchwork.ozlabs.org/patch/159139/.

Regards,

Stefan Weil
Stefan Hajnoczi June 11, 2012, 12:19 p.m. UTC | #3
On Mon, May 14, 2012 at 8:47 PM, Stefan Weil <sw@weilnetz.de> wrote:
> 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>
> ---
>  readline.c |    3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Luiz Capitulino June 12, 2012, 7:42 p.m. UTC | #4
On Sat, 09 Jun 2012 23:36:26 +0200
Stefan Weil <sw@weilnetz.de> wrote:

> Am 22.05.2012 22:24, schrieb Stefan Weil:
> > Am 14.05.2012 21:47, schrieb Stefan Weil:
> >> 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>
> >> ---
> >>   readline.c |    3 +++
> >>   1 file changed, 3 insertions(+)
> >>
> >> diff --git a/readline.c b/readline.c
> >> index a6c0039..646b6e8 100644
> >> --- a/readline.c
> >> +++ b/readline.c
> >> @@ -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 */
> >
> > Ping?
> >
> > This patch is for QEMU 1.1, but was not committed up to now.
> >
> > Regards,
> > Stefan Weil
> >
> 
> 
> Ping^2? Should I send a pull request?
> The patch is available at http://patchwork.ozlabs.org/patch/159139/.

Applied to the qmp branch, thanks.

Patch
diff mbox

diff --git a/readline.c b/readline.c
index a6c0039..646b6e8 100644
--- a/readline.c
+++ b/readline.c
@@ -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 */