Repository navigation
Cast the MQTT handler, not its address, when applying changed config - #1279
Merged
Merged
Conversation
When the MQTT config changed but the payload format did not, MQTT_connect() cast &mqttHandler (the address of the global pointer) to the Domoticz or Home Assistant handler type. setDomoticzConfig() and setHomeAssistantConfig() then wrote into the globals around that pointer instead of into the handler, corrupting memory and leaving the handler on its old config. Co-Authored-By: Claude Opus 5.5 <[email protected]>
🔧 PR Build ArtifactsVersion: All environments built successfully. Download the zip files:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
MQTT_connect(), when the MQTT config has changed but the payload format is unchanged, the existing handler is updated in place. For Domoticz (3) and Home Assistant (4) the code did:&mqttHandleris the address of the globalAmsMqttHandler*variable, not the handler object.setDomoticzConfig()andsetHomeAssistantConfig()therefore wrote their fields (includingStringassignments for HA) into whatever globals sit next tomqttHandler, and the real handler kept its old Domoticz/HA config.Fix
Cast
mqttHandleritself.Found while reviewing #1267, which fixes the
getFormat()mismatch that previously made this path unreachable for some formats (for 3 and 4 it was always reachable).Tested
Builds for
esp8266(flash 1 022 447 bytes, 97.9 %) andesp32. Not exercised on a device.🤖 Generated with Claude Code