From: akallabeth Date: Fri, 15 May 2020 14:38:42 +0000 (+0200) Subject: Fixed memory leak in NTLM test X-Git-Tag: 2.1.1^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2897576c3dee3b8d21e41792aeabae1f12437d95;p=platform%2Fupstream%2Ffreerdp.git Fixed memory leak in NTLM test (cherry picked from commit 135458cf27160d50e6294f87ef80f27f1f65d319) --- diff --git a/winpr/libwinpr/sspi/test/TestNTLM.c b/winpr/libwinpr/sspi/test/TestNTLM.c index 83abe70..82d266f 100644 --- a/winpr/libwinpr/sspi/test/TestNTLM.c +++ b/winpr/libwinpr/sspi/test/TestNTLM.c @@ -470,10 +470,15 @@ void test_ntlm_server_free(TEST_NTLM_SERVER* ntlm) int TestNTLM(int argc, char* argv[]) { int status; + int rc = -1; PSecBuffer pSecBuffer; - TEST_NTLM_CLIENT* client; - TEST_NTLM_SERVER* server; + TEST_NTLM_CLIENT* client = NULL; + TEST_NTLM_SERVER* server = NULL; BOOL DynamicTest = TRUE; + + WINPR_UNUSED(argc); + WINPR_UNUSED(argv); + /** * Client Initialization */ @@ -482,7 +487,7 @@ int TestNTLM(int argc, char* argv[]) if (!client) { printf("Memory allocation failed"); - return -1; + goto fail; } status = test_ntlm_client_init(client, TEST_NTLM_USER, TEST_NTLM_DOMAIN, TEST_NTLM_PASSWORD); @@ -490,7 +495,7 @@ int TestNTLM(int argc, char* argv[]) if (status < 0) { printf("test_ntlm_client_init failure\n"); - return -1; + goto fail; } /** @@ -501,7 +506,7 @@ int TestNTLM(int argc, char* argv[]) if (!server) { printf("Memory allocation failed\n"); - return -1; + goto fail; } status = test_ntlm_server_init(server); @@ -509,7 +514,7 @@ int TestNTLM(int argc, char* argv[]) if (status < 0) { printf("test_ntlm_server_init failure\n"); - return -1; + goto fail; } /** @@ -520,7 +525,7 @@ int TestNTLM(int argc, char* argv[]) if (status < 0) { printf("test_ntlm_client_authenticate failure\n"); - return -1; + goto fail; } if (!DynamicTest) @@ -557,7 +562,7 @@ int TestNTLM(int argc, char* argv[]) if (!pSecBuffer->pvBuffer) { printf("Memory allocation failed\n"); - return -1; + goto fail; } CopyMemory(pSecBuffer->pvBuffer, TEST_NTLM_NEGOTIATE, pSecBuffer->cbBuffer); @@ -578,7 +583,7 @@ int TestNTLM(int argc, char* argv[]) if (status < 0) { printf("test_ntlm_server_authenticate failure\n"); - return -1; + goto fail; } if (!DynamicTest) @@ -616,7 +621,7 @@ int TestNTLM(int argc, char* argv[]) if (!pSecBuffer->pvBuffer) { printf("Memory allocation failed\n"); - return -1; + goto fail; } CopyMemory(pSecBuffer->pvBuffer, TEST_NTLM_CHALLENGE, pSecBuffer->cbBuffer); @@ -643,7 +648,7 @@ int TestNTLM(int argc, char* argv[]) if (status < 0) { printf("test_ntlm_client_authenticate failure\n"); - return -1; + goto fail; } pSecBuffer = &(client->outputBuffer[0]); @@ -656,7 +661,7 @@ int TestNTLM(int argc, char* argv[]) if (!pSecBuffer->pvBuffer) { printf("Memory allocation failed\n"); - return -1; + goto fail; } CopyMemory(pSecBuffer->pvBuffer, TEST_NTLM_AUTHENTICATE, pSecBuffer->cbBuffer); @@ -676,13 +681,16 @@ int TestNTLM(int argc, char* argv[]) if (status < 0) { printf("test_ntlm_server_authenticate failure\n"); - return -1; + goto fail; } + rc = 0; + +fail: /** * Cleanup & Termination */ test_ntlm_client_free(client); test_ntlm_server_free(server); - return 0; + return rc; }