From eadf4036e7ccfcb98e7347b16b473b745b28a5e1 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Fri, 30 Mar 2012 23:27:21 +0200 Subject: [PATCH] wfreerdp: handle invalid command line arguments in a slightly more elegant way --- client/Windows/wfreerdp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index b0f4f6a83..7c1d79144 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -684,12 +684,25 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine //while (1) { + int arg_parse_result; + data = (thread_data*) xzalloc(sizeof(thread_data)); data->instance = instance; - freerdp_parse_args(instance->settings, __argc, __argv, + arg_parse_result = freerdp_parse_args(instance->settings, __argc, __argv, wf_process_plugin_args, instance->context->channels, wf_process_client_args, NULL); + if (arg_parse_result < 0) + { + if (arg_parse_result == FREERDP_ARGS_PARSE_FAILURE) + printf("failed to parse arguments.\n"); + +#ifdef _DEBUG + system("pause"); +#endif + exit(-1); + } + if (CreateThread(NULL, 0, thread_func, data, 0, NULL) != 0) g_thread_count++; }