From cbfa476d06d516f56eac6591a16a83fbe3e1bd65 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 2 Feb 2026 19:38:49 -0500 Subject: [PATCH] fix: initialize mosquittopp base class in initializer list The MQTT constructor was incorrectly attempting to call the base class constructor in the constructor body: mosquittopp(name.c_str()); This creates a temporary mosquittopp object that is immediately destroyed, leaving the actual base class uninitialized. When connect() is subsequently called, it uses methods from the uninitialized base class, causing a segfault. Move the base class initialization to the member initializer list where it belongs. Co-Authored-By: Claude Opus 4.5 --- src/zm_mqtt.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/zm_mqtt.cpp b/src/zm_mqtt.cpp index 11cb88382..5313b6a63 100644 --- a/src/zm_mqtt.cpp +++ b/src/zm_mqtt.cpp @@ -9,12 +9,10 @@ #include MQTT::MQTT(Monitor *monitor) : + mosqpp::mosquittopp(("ZoneMinder"+std::to_string(monitor->Id())).c_str()), monitor_(monitor), connected_(false) { - std::string name="ZoneMinder"+std::to_string(monitor->Id()); - mosquittopp(name.c_str()); - mosqpp::lib_init(); connect(); }