diff --git a/client/common/compatibility.c b/client/common/compatibility.c index 2d4e3074e..80b860acf 100644 --- a/client/common/compatibility.c +++ b/client/common/compatibility.c @@ -340,8 +340,10 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count) flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH; flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED; - settings = (rdpSettings*) malloc(sizeof(rdpSettings)); - ZeroMemory(settings, sizeof(rdpSettings)); + settings = (rdpSettings*) calloc(1, sizeof(rdpSettings)); + + if (!settings) + return -1; CommandLineClearArgumentsA(old_args); diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index df6e51c73..3e051ab7b 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -4,88 +4,97 @@ #include #include -#define TESTCASE(cmd, expected_return) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd, FALSE); \ - if (status != expected_return) { \ - printf("Test argument %s failed\n", #cmd); \ - return -1; \ - } +#define TESTCASE(cmd, expected_return) \ +{ \ + rdpSettings* settings = freerdp_settings_new(0); \ + status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd, FALSE); \ + freerdp_settings_free(settings); \ + if (status != expected_return) { \ + printf("Test argument %s failed\n", #cmd); \ + return -1; \ + } \ +} -#define TESTCASE_SUCCESS(cmd) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd, FALSE); \ - if (status < 0) { \ - printf("Test argument %s failed\n", #cmd); \ - return -1; \ - } +#define TESTCASE_SUCCESS(cmd) \ +{ \ + rdpSettings* settings = freerdp_settings_new(0); \ + status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd, FALSE); \ + freerdp_settings_free(settings); \ + if (status < 0) { \ + printf("Test argument %s failed\n", #cmd); \ + return -1; \ + } \ +} int TestClientCmdLine(int argc, char* argv[]) { int status; - rdpSettings* settings = freerdp_settings_new(0); - char* cmd1[] = {"xfreerdp", "--help"}; + char* cmd2[] = {"xfreerdp", "/help"}; + char* cmd3[] = {"xfreerdp", "-help"}; + char* cmd4[] = {"xfreerdp", "--version"}; + char* cmd5[] = {"xfreerdp", "/version"}; + char* cmd6[] = {"xfreerdp", "-version"}; + char* cmd7[] = {"xfreerdp", "test.freerdp.com"}; + char* cmd8[] = {"xfreerdp", "-v", "test.freerdp.com"}; + char* cmd9[] = {"xfreerdp", "--v", "test.freerdp.com"}; + char* cmd10[] = {"xfreerdp", "/v:test.freerdp.com"}; + char* cmd11[] = {"xfreerdp", "--plugin", "rdpsnd", "--plugin", "rdpdr", "--data", "disk:media:/tmp", "--", "test.freerdp.com" }; + char* cmd12[] = {"xfreerdp", "/sound", "/drive:media:/tmp", "/v:test.freerdp.com" }; + char* cmd13[] = {"xfreerdp", "-u", "test", "-p", "test", "test.freerdp.com"}; + char* cmd14[] = {"xfreerdp", "-u", "test", "-p", "test", "-v", "test.freerdp.com"}; + char* cmd15[] = {"xfreerdp", "/u:test", "/p:test", "/v:test.freerdp.com"}; + char* cmd16[] = {"xfreerdp", "-invalid"}; + char* cmd17[] = {"xfreerdp", "--invalid"}; + char* cmd18[] = {"xfreerdp", "/kbd-list"}; + char* cmd19[] = {"xfreerdp", "/monitor-list"}; + TESTCASE(cmd1, COMMAND_LINE_STATUS_PRINT_HELP); - char* cmd2[] = {"xfreerdp", "/help"}; TESTCASE(cmd2, COMMAND_LINE_STATUS_PRINT_HELP); - char* cmd3[] = {"xfreerdp", "-help"}; TESTCASE(cmd3, COMMAND_LINE_STATUS_PRINT_HELP); - char* cmd4[] = {"xfreerdp", "--version"}; TESTCASE(cmd4, COMMAND_LINE_STATUS_PRINT_VERSION); - char* cmd5[] = {"xfreerdp", "/version"}; TESTCASE(cmd5, COMMAND_LINE_STATUS_PRINT_VERSION); - char* cmd6[] = {"xfreerdp", "-version"}; TESTCASE(cmd6, COMMAND_LINE_STATUS_PRINT_VERSION); - char* cmd7[] = {"xfreerdp", "test.freerdp.com"}; TESTCASE_SUCCESS(cmd7); - char* cmd8[] = {"xfreerdp", "-v", "test.freerdp.com"}; TESTCASE_SUCCESS(cmd8); - char* cmd9[] = {"xfreerdp", "--v", "test.freerdp.com"}; TESTCASE_SUCCESS(cmd9); - char* cmd10[] = {"xfreerdp", "/v:test.freerdp.com"}; TESTCASE_SUCCESS(cmd10); - char* cmd11[] = {"xfreerdp", "--plugin", "rdpsnd", "--plugin", "rdpdr", "--data", "disk:media:/tmp", "--", "test.freerdp.com" }; TESTCASE_SUCCESS(cmd11); - char* cmd12[] = {"xfreerdp", "/sound", "/drive:media:/tmp", "/v:test.freerdp.com" }; TESTCASE_SUCCESS(cmd12); // password gets overwritten therefore it need to be writeable - char* cmd13[6] = {"xfreerdp", "-u", "test", "-p", "test", "test.freerdp.com"}; cmd13[4] = malloc(5); strncpy(cmd13[4], "test", 4); TESTCASE_SUCCESS(cmd13); free(cmd13[4]); - char* cmd14[] = {"xfreerdp", "-u", "test", "-p", "test", "-v", "test.freerdp.com"}; cmd14[4] = malloc(5); strncpy(cmd14[4], "test", 4); TESTCASE_SUCCESS(cmd14); free(cmd14[4]); - char* cmd15[] = {"xfreerdp", "/u:test", "/p:test", "/v:test.freerdp.com"}; cmd15[2] = malloc(7); strncpy(cmd15[2], "/p:test", 6); TESTCASE_SUCCESS(cmd15); free(cmd15[2]); - char* cmd16[] = {"xfreerdp", "-invalid"}; TESTCASE(cmd16, COMMAND_LINE_ERROR_NO_KEYWORD); - char* cmd17[] = {"xfreerdp", "--invalid"}; TESTCASE(cmd17, COMMAND_LINE_ERROR_NO_KEYWORD); - char* cmd18[] = {"xfreerdp", "/kbd-list"}; TESTCASE(cmd18, COMMAND_LINE_STATUS_PRINT); - char* cmd19[] = {"xfreerdp", "/monitor-list"}; TESTCASE(cmd19, COMMAND_LINE_STATUS_PRINT); #if 0 diff --git a/libfreerdp/gdi/test/TestGdiClip.c b/libfreerdp/gdi/test/TestGdiClip.c index fdf5fa39c..667f640e5 100644 --- a/libfreerdp/gdi/test/TestGdiClip.c +++ b/libfreerdp/gdi/test/TestGdiClip.c @@ -180,13 +180,13 @@ int test_gdi_InvalidateRegion(void) gdi_SelectObject(hdc, (HGDIOBJECT) bmp); gdi_SetNullClipRgn(hdc); - hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND)); + hdc->hwnd = (HGDI_WND) calloc(1, sizeof(GDI_WND)); hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0); hdc->hwnd->invalid->null = 1; invalid = hdc->hwnd->invalid; hdc->hwnd->count = 16; - hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * hdc->hwnd->count); + hdc->hwnd->cinvalid = (HGDI_RGN) calloc(hdc->hwnd->count, sizeof(GDI_RGN)); rgn1 = gdi_CreateRectRgn(0, 0, 0, 0); rgn2 = gdi_CreateRectRgn(0, 0, 0, 0); @@ -338,9 +338,13 @@ int test_gdi_InvalidateRegion(void) int TestGdiClip(int argc, char* argv[]) { + fprintf(stderr, "test_gdi_ClipCoords()\n"); + if (test_gdi_ClipCoords() < 0) return -1; + fprintf(stderr, "test_gdi_InvalidateRegion()\n"); + if (test_gdi_InvalidateRegion() < 0) return -1;