mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-15 12:44:04 +00:00
qemu-io: Fix memory leak
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
36ecd7c016
commit
40a0d7c395
10
qemu-io.c
10
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 *sizes = calloc(nr_iov, sizeof(size_t));
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
void *buf, *p;
|
void *buf = NULL;
|
||||||
|
void *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nr_iov; 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);
|
len = cvtnum(arg);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
printf("non-numeric length argument -- %s\n", arg);
|
printf("non-numeric length argument -- %s\n", arg);
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should be SIZE_T_MAX, but that doesn't exist */
|
/* should be SIZE_T_MAX, but that doesn't exist */
|
||||||
if (len > UINT_MAX) {
|
if (len > UINT_MAX) {
|
||||||
printf("too large length argument -- %s\n", arg);
|
printf("too large length argument -- %s\n", arg);
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len & 0x1ff) {
|
if (len & 0x1ff) {
|
||||||
printf("length argument %lld is not sector aligned\n",
|
printf("length argument %lld is not sector aligned\n",
|
||||||
len);
|
len);
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes[i] = len;
|
sizes[i] = len;
|
||||||
@ -167,6 +168,7 @@ create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
|
|||||||
p += sizes[i];
|
p += sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
free(sizes);
|
free(sizes);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user