From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH] qemu-io: Fix memory leak
Date: Wed, 18 Nov 2009 10:42:59 +0100 [thread overview]
Message-ID: <1258537379-25369-1-git-send-email-kwolf@redhat.com> (raw)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-io.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index cac72e9..c84b361 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -129,7 +129,8 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
{
size_t *sizes = calloc(nr_iov, sizeof(size_t));
size_t count = 0;
- void *buf, *p;
+ void *buf = NULL;
+ void *p;
int i;
for (i = 0; i < nr_iov; i++) {
@@ -139,19 +140,19 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
len = cvtnum(arg);
if (len < 0) {
printf("non-numeric length argument -- %s\n", arg);
- return NULL;
+ goto fail;
}
/* should be SIZE_T_MAX, but that doesn't exist */
if (len > UINT_MAX) {
printf("too large length argument -- %s\n", arg);
- return NULL;
+ goto fail;
}
if (len & 0x1ff) {
printf("length argument %lld is not sector aligned\n",
len);
- return NULL;
+ goto fail;
}
sizes[i] = len;
@@ -167,6 +168,7 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
p += sizes[i];
}
+fail:
free(sizes);
return buf;
}
--
1.6.2.5
next reply other threads:[~2009-11-18 9:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-18 9:42 Kevin Wolf [this message]
2009-11-18 19:04 ` [Qemu-devel] [PATCH] qemu-io: Fix memory leak Christoph Hellwig
2009-11-20 8:05 ` Amit Shah
2009-11-20 8:35 ` Kevin Wolf
-- strict thread matches above, loose matches on Subject: below --
2009-07-08 12:21 Kevin Wolf
2009-07-08 14:11 ` Christoph Hellwig
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=1258537379-25369-1-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@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).