mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-01 20:05:19 +00:00
virISCSIGetSession: Don't leak memory
This function runs an iscsi command and parses its output. However, due to the nature of things, virISCSIExtractSession() callback can be called multiple times. In each run it would allocate new memory and overwrite the variable where we keep pointer to it and thus leaking old allocations. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> (cherry picked from commit 9c037c6caea6155bad82eb3a204af68dcdaf7409)
This commit is contained in:
parent
9e8d33ae1c
commit
f59163c46d
@ -52,7 +52,8 @@ virISCSIExtractSession(char **const groups,
|
||||
{
|
||||
struct virISCSISessionData *data = opaque;
|
||||
|
||||
if (STREQ(groups[1], data->devpath))
|
||||
if (!data->session &&
|
||||
STREQ(groups[1], data->devpath))
|
||||
return VIR_STRDUP(data->session, groups[0]);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user