ui: Plug memory leaks on parse_keyboard_layout() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Markus Armbruster 2011-11-11 10:40:06 +01:00 committed by Anthony Liguori
parent a4e2604852
commit f2d3476eba

View file

@ -92,15 +92,17 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
if (!k)
k = g_malloc0(sizeof(kbd_layout_t));
if (!(filename && (f = fopen(filename, "r")))) {
f = filename ? fopen(filename, "r") : NULL;
g_free(filename);
if (!f) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
g_free(filename);
if (!k)
k = g_malloc0(sizeof(kbd_layout_t));
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;