* [PATCH] ui/cocoa: Fix the leak of qemu_console_get_label
@ 2022-02-13 2:13 Akihiko Odaki
2022-02-13 11:11 ` BALATON Zoltan
0 siblings, 1 reply; 3+ messages in thread
From: Akihiko Odaki @ 2022-02-13 2:13 UTC (permalink / raw)
Cc: Peter Maydell, qemu-devel, Akihiko Odaki, Gerd Hoffmann
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
ui/cocoa.m | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index ac18e14ce01..fdf52a7c2f7 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1680,7 +1680,10 @@ static void create_initial_menus(void)
/* Returns a name for a given console */
static NSString * getConsoleName(QemuConsole * console)
{
- return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)];
+ char *label = qemu_console_get_label(console);
+ NSString *nslabel = [NSString stringWithUTF8String:label];
+ g_free(label);
+ return nslabel;
}
/* Add an entry to the View menu for each console */
--
2.32.0 (Apple Git-132)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ui/cocoa: Fix the leak of qemu_console_get_label
2022-02-13 2:13 [PATCH] ui/cocoa: Fix the leak of qemu_console_get_label Akihiko Odaki
@ 2022-02-13 11:11 ` BALATON Zoltan
2022-02-15 8:02 ` Philippe Mathieu-Daudé via
0 siblings, 1 reply; 3+ messages in thread
From: BALATON Zoltan @ 2022-02-13 11:11 UTC (permalink / raw)
To: Akihiko Odaki; +Cc: Peter Maydell, qemu-devel, Gerd Hoffmann
On Sun, 13 Feb 2022, Akihiko Odaki wrote:
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> ---
> ui/cocoa.m | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index ac18e14ce01..fdf52a7c2f7 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -1680,7 +1680,10 @@ static void create_initial_menus(void)
> /* Returns a name for a given console */
> static NSString * getConsoleName(QemuConsole * console)
> {
> - return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)];
> + char *label = qemu_console_get_label(console);
I guess you could do g_autofree char *label to save a g_free but not a big
deal and only saves one line here so it's also good as it is.
Regards,
BALATON Zoltan
> + NSString *nslabel = [NSString stringWithUTF8String:label];
> + g_free(label);
> + return nslabel;
> }
>
> /* Add an entry to the View menu for each console */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ui/cocoa: Fix the leak of qemu_console_get_label
2022-02-13 11:11 ` BALATON Zoltan
@ 2022-02-15 8:02 ` Philippe Mathieu-Daudé via
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-15 8:02 UTC (permalink / raw)
To: BALATON Zoltan, Akihiko Odaki; +Cc: Peter Maydell, qemu-devel, Gerd Hoffmann
On 13/2/22 12:11, BALATON Zoltan wrote:
> On Sun, 13 Feb 2022, Akihiko Odaki wrote:
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
>> ---
>> ui/cocoa.m | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>> index ac18e14ce01..fdf52a7c2f7 100644
>> --- a/ui/cocoa.m
>> +++ b/ui/cocoa.m
>> @@ -1680,7 +1680,10 @@ static void create_initial_menus(void)
>> /* Returns a name for a given console */
>> static NSString * getConsoleName(QemuConsole * console)
>> {
>> - return [NSString stringWithFormat: @"%s",
>> qemu_console_get_label(console)];
>> + char *label = qemu_console_get_label(console);
>
> I guess you could do g_autofree char *label to save a g_free but not a
> big deal and only saves one line here so it's also good as it is.
Good idea.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-15 8:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-13 2:13 [PATCH] ui/cocoa: Fix the leak of qemu_console_get_label Akihiko Odaki
2022-02-13 11:11 ` BALATON Zoltan
2022-02-15 8:02 ` Philippe Mathieu-Daudé via
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.