提交 9c037c6c 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
上级 c455591f
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册