Fixed memory leak
This commit is contained in:
parent
4b72a85e91
commit
b59e39b3eb
@ -170,7 +170,8 @@ static int testAbort(int port)
|
|||||||
|
|
||||||
static int testSuccess(int port)
|
static int testSuccess(int port)
|
||||||
{
|
{
|
||||||
int rc;
|
int r;
|
||||||
|
int rc = -2;
|
||||||
STARTUPINFOA si;
|
STARTUPINFOA si;
|
||||||
PROCESS_INFORMATION process;
|
PROCESS_INFORMATION process;
|
||||||
char arg1[] = "/v:127.0.0.1:XXXXX";
|
char arg1[] = "/v:127.0.0.1:XXXXX";
|
||||||
@ -182,66 +183,42 @@ static int testSuccess(int port)
|
|||||||
"/rfx",
|
"/rfx",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
char* commandLine;
|
char* commandLine = NULL;
|
||||||
int commandLineLen;
|
int commandLineLen;
|
||||||
int argc = 4;
|
int argc = 4;
|
||||||
char* path = TESTING_OUTPUT_DIRECTORY;
|
char* path = NULL;
|
||||||
char* wpath = TESTING_SRC_DIRECTORY;
|
char* wpath = NULL;
|
||||||
char* exe = GetCombinedPath(path, "server");
|
char* exe = GetCombinedPath(TESTING_OUTPUT_DIRECTORY, "server");
|
||||||
char* wexe = GetCombinedPath(wpath, "server");
|
char* wexe = GetCombinedPath(TESTING_SRC_DIRECTORY, "server");
|
||||||
_snprintf(arg1, 18, "/v:127.0.0.1:%d", port);
|
_snprintf(arg1, 18, "/v:127.0.0.1:%d", port);
|
||||||
clientArgs[1] = arg1;
|
clientArgs[1] = arg1;
|
||||||
|
|
||||||
if (!exe || !wexe)
|
if (!exe || !wexe)
|
||||||
{
|
goto fail;
|
||||||
free(exe);
|
|
||||||
free(wexe);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = GetCombinedPath(exe, "Sample");
|
path = GetCombinedPath(exe, "Sample");
|
||||||
wpath = GetCombinedPath(wexe, "Sample");
|
wpath = GetCombinedPath(wexe, "Sample");
|
||||||
free(exe);
|
|
||||||
free(wexe);
|
|
||||||
|
|
||||||
if (!path || !wpath)
|
if (!path || !wpath)
|
||||||
{
|
goto fail;
|
||||||
free(path);
|
|
||||||
free(wpath);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
exe = GetCombinedPath(path, "sfreerdp-server");
|
exe = GetCombinedPath(path, "sfreerdp-server");
|
||||||
|
|
||||||
if (!exe)
|
if (!exe)
|
||||||
{
|
goto fail;
|
||||||
free(path);
|
|
||||||
free(wpath);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Sample Server: %s\n", exe);
|
printf("Sample Server: %s\n", exe);
|
||||||
printf("Workspace: %s\n", wpath);
|
printf("Workspace: %s\n", wpath);
|
||||||
|
|
||||||
if (!PathFileExistsA(exe))
|
if (!PathFileExistsA(exe))
|
||||||
{
|
goto fail;
|
||||||
free(path);
|
|
||||||
free(wpath);
|
|
||||||
free(exe);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start sample server locally.
|
// Start sample server locally.
|
||||||
commandLineLen = strlen(exe) + strlen("--local-only --port=XXXXX") + 1;
|
commandLineLen = strlen(exe) + strlen("--local-only --port=XXXXX") + 1;
|
||||||
commandLine = malloc(commandLineLen);
|
commandLine = malloc(commandLineLen);
|
||||||
|
|
||||||
if (!commandLine)
|
if (!commandLine)
|
||||||
{
|
goto fail;
|
||||||
free(path);
|
|
||||||
free(wpath);
|
|
||||||
free(exe);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
_snprintf(commandLine, commandLineLen, "%s --local-only --port=%d", exe, port);
|
_snprintf(commandLine, commandLineLen, "%s --local-only --port=%d", exe, port);
|
||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
@ -249,33 +226,29 @@ static int testSuccess(int port)
|
|||||||
|
|
||||||
if (!CreateProcessA(exe, commandLine, NULL, NULL, FALSE, 0, NULL,
|
if (!CreateProcessA(exe, commandLine, NULL, NULL, FALSE, 0, NULL,
|
||||||
wpath, &si, &process))
|
wpath, &si, &process))
|
||||||
{
|
goto fail;
|
||||||
free(exe);
|
|
||||||
free(path);
|
|
||||||
free(wpath);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(exe);
|
|
||||||
free(path);
|
|
||||||
free(wpath);
|
|
||||||
free(commandLine);
|
|
||||||
Sleep(1 * 1000); /* let the server start */
|
Sleep(1 * 1000); /* let the server start */
|
||||||
rc = runInstance(argc, clientArgs, NULL);
|
r = runInstance(argc, clientArgs, NULL);
|
||||||
|
|
||||||
if (!TerminateProcess(process.hProcess, 0))
|
if (!TerminateProcess(process.hProcess, 0))
|
||||||
return -2;
|
goto fail;
|
||||||
|
|
||||||
WaitForSingleObject(process.hProcess, INFINITE);
|
WaitForSingleObject(process.hProcess, INFINITE);
|
||||||
CloseHandle(process.hProcess);
|
CloseHandle(process.hProcess);
|
||||||
CloseHandle(process.hThread);
|
CloseHandle(process.hThread);
|
||||||
printf("%s: returned %d!\n", __FUNCTION__, rc);
|
printf("%s: returned %d!\n", __FUNCTION__, r);
|
||||||
|
rc = r;
|
||||||
|
|
||||||
if (rc)
|
if (rc == 0)
|
||||||
return -1;
|
printf("%s: Success!\n", __FUNCTION__);
|
||||||
|
|
||||||
printf("%s: Success!\n", __FUNCTION__);
|
fail:
|
||||||
return 0;
|
free(exe);
|
||||||
|
free(path);
|
||||||
|
free(wpath);
|
||||||
|
free(commandLine);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TestConnect(int argc, char* argv[])
|
int TestConnect(int argc, char* argv[])
|
||||||
|
Loading…
Reference in New Issue
Block a user