summaryrefslogtreecommitdiff
path: root/qemu-io.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2009-11-18 10:42:59 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-18 11:26:26 -0600
commit40a0d7c395f4d18a8061ba075d8f9aab2fa0ec2a (patch)
tree8677fbc76b8e8396e26ab4e758cf3ea1d8a3e152 /qemu-io.c
parent36ecd7c016f682437941a54193251cbf918bef0d (diff)
downloadqemu-40a0d7c395f4d18a8061ba075d8f9aab2fa0ec2a.tar.gz
qemu-40a0d7c395f4d18a8061ba075d8f9aab2fa0ec2a.tar.bz2
qemu-40a0d7c395f4d18a8061ba075d8f9aab2fa0ec2a.zip
qemu-io: Fix memory leak
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-io.c')
-rw-r--r--qemu-io.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/qemu-io.c b/qemu-io.c
index 25c282ec09..aa26e36b85 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;
}