From 0a3e54480a509d5d323a31440af67a63a990d80e Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 22 Nov 2015 17:48:04 +0300 Subject: [PATCH] sc: Fix service handle leak on error path (Coverity). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- programs/sc/sc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/programs/sc/sc.c b/programs/sc/sc.c index 2cfe91c633e..0bf5d0634d3 100644 --- a/programs/sc/sc.c +++ b/programs/sc/sc.c @@ -285,15 +285,14 @@ int wmain( int argc, const WCHAR *argv[] ) if (service) { SERVICE_FAILURE_ACTIONSW sfa; - if (!parse_failure_params( argc - 3, argv + 3, &sfa )) + if (parse_failure_params( argc - 3, argv + 3, &sfa )) { - WINE_WARN("failed to parse failure parameters\n"); - CloseServiceHandle( manager ); - return 1; + ret = ChangeServiceConfig2W( service, SERVICE_CONFIG_FAILURE_ACTIONS, &sfa ); + if (!ret) WINE_TRACE("failed to set service failure actions %u\n", GetLastError()); + HeapFree( GetProcessHeap(), 0, sfa.lpsaActions ); } - ret = ChangeServiceConfig2W( service, SERVICE_CONFIG_FAILURE_ACTIONS, &sfa ); - if (!ret) WINE_TRACE("failed to set service failure actions %u\n", GetLastError()); - HeapFree( GetProcessHeap(), 0, sfa.lpsaActions ); + else + WINE_WARN("failed to parse failure parameters\n"); CloseServiceHandle( service ); } else WINE_TRACE("failed to open service %u\n", GetLastError());