Skip to content
Permalink
Browse files

Fix segfault when there's no http{} block in nginx.conf (#1221)

Should fix #1220
  • Loading branch information
oschaaf authored and crowell committed Jul 21, 2016
1 parent b26e174 commit ff8969770d2914a4ffa8473b019ad743e1a84652
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/ngx_pagespeed.cc
@@ -2938,7 +2938,7 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
ngx_int_t ps_etag_filter_init(ngx_conf_t* cf) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
if (cfg_m->driver_factory != NULL) {
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
ngx_http_ef_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ps_etag_header_filter;
}
@@ -3020,6 +3020,11 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));

// See https://github.com/pagespeed/ngx_pagespeed/issues/1220
if (cfg_m == NULL) {
return NGX_OK;
}

ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module));
ngx_http_core_srv_conf_t** cscfp = static_cast<ngx_http_core_srv_conf_t**>(
@@ -3087,7 +3092,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
NgxBaseFetch::Terminate();
if (cfg_m->driver_factory != NULL) {
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
cfg_m->driver_factory->ShutDown();
}
}
@@ -3097,7 +3102,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
if (cfg_m->driver_factory == NULL) {
if (cfg_m == NULL || cfg_m->driver_factory == NULL) {
return NGX_OK;
}

0 comments on commit ff89697

Please sign in to comment.