diff options
author | Daniel Xu <dxu@dxuuu.xyz> | 2023-10-01 12:38:25 -0600 |
---|---|---|
committer | Konstantin Kostiuk <kkostiuk@redhat.com> | 2023-10-11 14:30:54 +0300 |
commit | d6f67b83b81bf49b5c62e77143ed39c020e51830 (patch) | |
tree | 371532c16e5e2e0dc2bcb7a6e6c04ccdacad2765 /tests | |
parent | 99bb31585cccd474b852deb29bd982e2ee542871 (diff) | |
download | qemu-d6f67b83b81bf49b5c62e77143ed39c020e51830.zip qemu-d6f67b83b81bf49b5c62e77143ed39c020e51830.tar.gz qemu-d6f67b83b81bf49b5c62e77143ed39c020e51830.tar.bz2 |
qga: Fix memory leak when output stream is unused
If capture-output is requested but one of the channels goes unused (eg.
we attempt to capture stderr but the command never writes to stderr), we
can leak memory.
guest_exec_output_watch() is (from what I understand) unconditionally
called for both streams if output capture is requested. The first call
will always pass the `p->size == p->length` check b/c both values are
0. Then GUEST_EXEC_IO_SIZE bytes will be allocated for the stream.
But when we reap the exited process there's a `gei->err.length > 0`
check to actually free the buffer. Which does not get run if the command
doesn't write to the stream.
Fix by making free() unconditional.
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Diffstat (limited to 'tests')
0 files changed, 0 insertions, 0 deletions