From 9b17dbf8a29861ffd23387c7e5520a7baaee1e88 Mon Sep 17 00:00:00 2001 From: Dmitry Plotnikov Date: Tue, 18 Apr 2023 19:09:26 +0000 Subject: [PATCH] Fix a crash for configs with no http block. --- src/http_module.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/http_module.cpp b/src/http_module.cpp index fde153f..4004fc1 100644 --- a/src/http_module.cpp +++ b/src/http_module.cpp @@ -552,6 +552,10 @@ ngx_int_t initWorkerProcess(ngx_cycle_t* cycle) auto mcf = (MainConf*)ngx_http_cycle_get_module_main_conf( cycle, gHttpModule); + if (mcf == NULL) { + return NGX_OK; + } + try { gExporter.reset(new BatchExporter( toStrView(mcf->endpoint), @@ -591,6 +595,10 @@ ngx_int_t initWorkerProcess(ngx_cycle_t* cycle) void exitWorkerProcess(ngx_cycle_t* cycle) { + if (!gExporter) { + return; + } + try { gExporter->flush(); } catch (const std::exception& e) {