aboutsummaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-05-19 15:26:03 +0800
committerMichael Roth <mdroth@linux.vnet.ibm.com>2014-06-03 15:07:59 -0500
commit374044f08fe18a18469b981812cd8695f5b3569c (patch)
tree73c93efb0b46f013d4aad430409c3ae77d659e50 /qga
parente00fcfeab3d452cba3d0a08991a39ab15df66424 (diff)
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: Wang Rui <moon.wangrui@huawei.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-win32.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index d793dd0c85..e76939651a 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -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);
}