On May 19, 2014, at 10:26 AM, arei.gong...@huawei.com wrote: > From: Gonglei <arei.gong...@huawei.com> > > token should be closed in all conditions. > So move CloseHandle(token) to "out" branch. > > Signed-off-by: Wang Rui <moon.wang...@huawei.com> > Signed-off-by: Gonglei <arei.gong...@huawei.com> > --- > qga/commands-win32.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/qga/commands-win32.c b/qga/commands-win32.c > index d793dd0..e769396 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); > } > -- > 1.7.12.4 >
Reviewed-by: Yan Vugenfirer <y...@daynix.com>