Fix listen_port check.
Interestingly, the bug depends on compiler behavior. If local variables are automatically initialized to 0, then this always caused the program to error out indicating a failure to parse the listen port. Otherwise, the test was a no-op (except the rare case where the memory happened to be zero anyways). Thanks to Eugen Melnikoff for finding this.
This commit is contained in:
parent
31407abc25
commit
1656b1b98d
|
@ -245,7 +245,7 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int listen_port, fd, c, option_index = 0;
|
int fd, c, option_index = 0;
|
||||||
static int ssl_only = 0, foreground = 0;
|
static int ssl_only = 0, foreground = 0;
|
||||||
char *found;
|
char *found;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
@ -309,7 +309,7 @@ int main(int argc, char *argv[])
|
||||||
settings.listen_port = strtol(argv[optind], NULL, 10);
|
settings.listen_port = strtol(argv[optind], NULL, 10);
|
||||||
}
|
}
|
||||||
optind++;
|
optind++;
|
||||||
if (listen_port == 0) {
|
if (settings.listen_port == 0) {
|
||||||
usage("Could not parse listen_port\n");
|
usage("Could not parse listen_port\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue