Skip to content

Commit

Permalink
ui: Plug memory leaks on parse_keyboard_layout() error path
Browse files Browse the repository at this point in the history
Spotted by Coverity.

Signed-off-by: Markus Armbruster <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
Markus Armbruster authored and Anthony Liguori committed Nov 11, 2011
1 parent a4e2604 commit f2d3476
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ui/keymaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f2d3476

Please sign in to comment.