]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Fix leak in qemuStringToArgvEnv upon OOM
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Sep 2013 15:34:06 +0000 (16:34 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 14:49:28 +0000 (15:49 +0100)
commitb391b19144e5daa3ce68d45468b05eb936d9b244
treed19a186148c9125b1d7b1336af33670e6c1d31fb
parent6bb7f19eb172754f999b47cda394f02ebddf2b3b
Fix leak in qemuStringToArgvEnv upon OOM

The 'qemuStringToArgvEnv' method splits up a string of command
line env/args to an 'arglist' array. It then copies env vars
to a 'progenv' array and args to a 'progargv' array. When
copyin the env vars, it NULL-ifies the element in 'arglist'
that is copied.

Upon OOM the 'virStringListFree' is called on progenv and
arglist. Unfortunately, because the elements in 'arglist'
related to env vars have been set to NULL, the call to
virStringListFree(arglist) doesn't free anything, even
though some non-NULL args vars still exist later in the
array.

To fix this leak, stop NULL-ifying the 'arglist' elements,
and change the cleanup code to only free elements in the
'arglist' array, not 'progenv'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/qemu/qemu_command.c