Skip to content

Commit

Permalink
qga: Fix handle fd leak in acquire_privilege()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gongleiarei authored and mdroth committed Jun 3, 2014
1 parent e00fcfe commit 374044f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qga/commands-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down

0 comments on commit 374044f

Please sign in to comment.