From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: [Qemu-trivial] [PATCH 2/5] ui: Plug memory leaks on parse_keyboard_layout() error path
Date: Fri, 11 Nov 2011 10:40:06 +0100 [thread overview]
Message-ID: <1321004409-3274-3-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1321004409-3274-1-git-send-email-armbru@redhat.com>
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
ui/keymaps.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/ui/keymaps.c b/ui/keymaps.c
index f54a114..f55a2aa 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -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;
--
1.7.6.4
next prev parent reply other threads:[~2011-11-11 9:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 9:40 [Qemu-trivial] [PATCH 0/5] Plug a few trivial resource leaks Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 1/5] qemu-char: Plug memory leak on qemu_chr_open_pty() error path Markus Armbruster
2011-11-11 9:40 ` Markus Armbruster [this message]
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 3/5] qemu-sockets: Plug fd leak on unix_connect_opts() " Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 4/5] posix-aio-compat: Plug memory leak on paio_init() " Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 5/5] os-posix: Plug fd leak in qemu_create_pidfile() Markus Armbruster
2011-11-11 19:46 ` [Qemu-trivial] [Qemu-devel] [PATCH 0/5] Plug a few trivial resource leaks Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321004409-3274-3-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).