Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit ff89697

Browse files
oschaafcrowell
authored andcommitted
Fix segfault when there's no http{} block in nginx.conf (#1221)
Should fix #1220
1 parent b26e174 commit ff89697

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ngx_pagespeed.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,7 +2938,7 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
29382938
ngx_int_t ps_etag_filter_init(ngx_conf_t* cf) {
29392939
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
29402940
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
2941-
if (cfg_m->driver_factory != NULL) {
2941+
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
29422942
ngx_http_ef_next_header_filter = ngx_http_top_header_filter;
29432943
ngx_http_top_header_filter = ps_etag_header_filter;
29442944
}
@@ -3020,6 +3020,11 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
30203020
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
30213021
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
30223022

3023+
// See https://github.com/pagespeed/ngx_pagespeed/issues/1220
3024+
if (cfg_m == NULL) {
3025+
return NGX_OK;
3026+
}
3027+
30233028
ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
30243029
ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module));
30253030
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) {
30873092
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
30883093
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
30893094
NgxBaseFetch::Terminate();
3090-
if (cfg_m->driver_factory != NULL) {
3095+
if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
30913096
cfg_m->driver_factory->ShutDown();
30923097
}
30933098
}
@@ -3097,7 +3102,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
30973102
ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
30983103
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
30993104
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
3100-
if (cfg_m->driver_factory == NULL) {
3105+
if (cfg_m == NULL || cfg_m->driver_factory == NULL) {
31013106
return NGX_OK;
31023107
}
31033108

0 commit comments

Comments
 (0)