From 5a6d15b7d02dd00d4052524c5a587939235443d0 Mon Sep 17 00:00:00 2001 From: Mikhail Kirichenko Date: Tue, 28 Nov 2017 14:39:44 +0300 Subject: [PATCH] RB-17343: fix ngx.graphite without graphite_config segfault --- src/ngx_http_graphite_module.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ngx_http_graphite_module.c b/src/ngx_http_graphite_module.c index e85dc5d..c83f223 100644 --- a/src/ngx_http_graphite_module.c +++ b/src/ngx_http_graphite_module.c @@ -699,8 +699,12 @@ ngx_http_graphite_context_from_request(ngx_http_request_t *r) { ngx_http_graphite_main_conf_t *gmcf = ngx_http_get_module_main_conf(r, ngx_http_graphite_module); - ngx_slab_pool_t *shpool = (ngx_slab_pool_t*)gmcf->shared->shm.addr; - ngx_http_graphite_storage_t *storage = (ngx_http_graphite_storage_t*)shpool->data; + ngx_http_graphite_storage_t *storage = NULL; + + if (gmcf->enable) { + ngx_slab_pool_t *shpool = (ngx_slab_pool_t*)gmcf->shared->shm.addr; + storage = (ngx_http_graphite_storage_t*)shpool->data; + } ngx_http_graphite_context_t context; context.phase = PHASE_REQUEST;