提交 374044f0 编写于 作者: G Gonglei 提交者: Michael Roth

qga: Fix handle fd leak in acquire_privilege()

token should be closed in all conditions.
So move CloseHandle(token) to "out" branch.
Signed-off-by: NWang Rui <moon.wangrui@huawei.com>
Signed-off-by: NGonglei <arei.gonglei@huawei.com>
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 e00fcfea
......@@ -31,7 +31,7 @@
static void acquire_privilege(const char *name, Error **errp)
{
HANDLE token;
HANDLE token = NULL;
TOKEN_PRIVILEGES priv;
Error *local_err = NULL;
......@@ -53,13 +53,15 @@ static void acquire_privilege(const char *name, Error **errp)
goto out;
}
CloseHandle(token);
} else {
error_set(&local_err, QERR_QGA_COMMAND_FAILED,
"failed to open privilege token");
}
out:
if (token) {
CloseHandle(token);
}
if (local_err) {
error_propagate(errp, local_err);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册