Factorize resource release after CreateProcess()
Free the wide characters string in all cases before checking for errors.
This commit is contained in:
parent
fd4ec784e0
commit
9cb8766220
1 changed files with 4 additions and 5 deletions
|
@ -94,10 +94,10 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle,
|
||||||
goto error_close_stderr;
|
goto error_close_stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateProcessW(NULL, wide, NULL, NULL, TRUE, 0, NULL, NULL, &si,
|
BOOL ok = CreateProcessW(NULL, wide, NULL, NULL, TRUE, 0, NULL, NULL, &si,
|
||||||
&pi)) {
|
&pi);
|
||||||
free(wide);
|
free(wide);
|
||||||
|
if (!ok) {
|
||||||
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
|
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
|
||||||
ret = SC_PROCESS_ERROR_MISSING_BINARY;
|
ret = SC_PROCESS_ERROR_MISSING_BINARY;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle,
|
||||||
CloseHandle(stderr_write_handle);
|
CloseHandle(stderr_write_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(wide);
|
|
||||||
*handle = pi.hProcess;
|
*handle = pi.hProcess;
|
||||||
|
|
||||||
return SC_PROCESS_SUCCESS;
|
return SC_PROCESS_SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue