ui/cocoa: Fix the leak of qemu_console_get_label
authorAkihiko Odaki <akihiko.odaki@gmail.com>
Tue, 15 Feb 2022 08:03:05 +0000 (09:03 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 21 Feb 2022 13:30:21 +0000 (13:30 +0000)
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20220215080307.69550-14-f4bug@amsat.org
Message-Id: <20220213021329.2066-1-akihiko.odaki@gmail.com>
[PMD: Use g_autofree, suggested by Zoltan BALATON]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
ui/cocoa.m

index f585a5c177d8c6bcb31a280b565d4803d0fec9fd..a8f1cdaf926fd62f792f3569900c50a4e4472b33 100644 (file)
@@ -1674,7 +1674,9 @@ 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)];
+    g_autofree char *label = qemu_console_get_label(console);
+
+    return [NSString stringWithUTF8String:label];
 }
 
 /* Add an entry to the View menu for each console */