summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2018-09-19 19:24:56 +0300
committerMax Romanov <max.romanov@nginx.com>2018-09-19 19:24:56 +0300
commite964e982fd64505fb8644f91e5c57a869038cd18 (patch)
tree260c3199190e8f5b2891c54281fa3046e6b31a79 /src
parent5ef1352fae50c3ca746387914e5b594e8e6e33fc (diff)
downloadunit-e964e982fd64505fb8644f91e5c57a869038cd18.tar.gz
unit-e964e982fd64505fb8644f91e5c57a869038cd18.tar.bz2
Initializing application structure with 0 to avoid crash.
Attribute 'application' is optional in listener object. This commit adds missing code to reset 'lscf' to avoid garbage and crash when the attribute is absent.
Diffstat (limited to '')
-rw-r--r--src/nxt_router.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 8f820895..df5b7466 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -1545,6 +1545,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
goto fail;
}
+ nxt_memzero(&lscf, sizeof(lscf));
+
ret = nxt_conf_map_object(mp, listener, nxt_router_listener_conf,
nxt_nitems(nxt_router_listener_conf), &lscf);
if (ret != NXT_OK) {
@@ -1577,9 +1579,12 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
skcf->listen->handler = nxt_http_conn_init;
skcf->router_conf = tmcf->router_conf;
skcf->router_conf->count++;
- skcf->application = nxt_router_listener_application(tmcf,
+
+ if (lscf.application.length > 0) {
+ skcf->application = nxt_router_listener_application(tmcf,
&lscf.application);
- nxt_router_app_use(task, skcf->application, 1);
+ nxt_router_app_use(task, skcf->application, 1);
+ }
}
value = nxt_conf_get_path(conf, &access_log_path);