mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-19 03:56:18 -04:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -9,12 +9,10 @@
|
||||
#include <string.h>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user