Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
580 stars 738 forks source link

Avoid double-free in amqp messaging module #2599

Closed ewertons closed 3 months ago

ewertons commented 3 months ago
# Checklist - [x] I have read the [contribution guidelines] (https://github.com/Azure/azure-iot-sdk-c/blob/main/.github/CONTRIBUTING.md). - [ ] I added or modified the existing tests to cover the change (we do not allow our test coverage to go down). - If this is a modification that impacts the behavior of a public API - [ ] I edited the corresponding document in the `devdoc` folder and added or modified requirements. - I submitted this PR against the correct branch: - [x] This pull-request is submitted against the `main` branch. - [x] I have merged the latest `main` branch prior to submission and re-merged as needed after I took any feedback. - [x] I have squashed my changes into one with a clear description of the change. # Reference/Link to the issue solved with this PR (if any) # Description of the problem Double free can occur on iothub amqp messenger due to an optimization that was done to free memory as early as possible. # Description of the solution Remove the optimization to fix the double free situation. Note: - There are no tests covering this area, but they should be added at some point. - There is no chance of leaks because of this change, because on_message_processing_completed_callback is always called and `message` will always be destroyed there.