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:
parent
a4e2604852
commit
f2d3476eba
12
ui/keymaps.c
12
ui/keymaps.c
@ -92,15 +92,17 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
|
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
|
||||||
|
f = filename ? fopen(filename, "r") : NULL;
|
||||||
if (!k)
|
g_free(filename);
|
||||||
k = g_malloc0(sizeof(kbd_layout_t));
|
if (!f) {
|
||||||
if (!(filename && (f = fopen(filename, "r")))) {
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Could not read keymap file: '%s'\n", language);
|
"Could not read keymap file: '%s'\n", language);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
g_free(filename);
|
|
||||||
|
if (!k)
|
||||||
|
k = g_malloc0(sizeof(kbd_layout_t));
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (fgets(line, 1024, f) == NULL)
|
if (fgets(line, 1024, f) == NULL)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user