This patch fixes a segfault in the command line parser.
When haproxy is launched with -x with no argument and -x is the latest
option in argv it segfaults.
Use usage() insteads of exit() on error.
else if (*flag == 'q')
arg_mode |= MODE_QUIET;
else if (*flag == 'x') {
- if (argv[1][0] == '-') {
- Alert("Unix socket path expected with the -x flag\n");
- exit(1);
+ if (argc <= 1 || argv[1][0] == '-') {
+ Alert("Unix socket path expected with the -x flag\n\n");
+ usage(progname);
}
old_unixsocket = argv[1];
argv++;