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
585 stars 739 forks source link

Avoid Bad arguments: value = (nil) error due to indicate_all_messages_as_error #2556

Closed ewertons closed 7 months ago

ewertons commented 7 months ago

The following callstack

amqpvalue_get_list_item_count (value=0x0, size=0x7fffffffda68) at uamqp/src/amqpvalue.c:1345 internal_on_event_send_complete_callback (context=0x55555627dd90, send_result=MESSAGE_SEND_ERROR, delivery_state=0x0) at iothub_client/src/iothubtransport_amqp_telemetry_messenger.c:986 indicate_all_messages_as_error (message_sender=0x555555b60860) at uamqp/src/message_sender.c:701 messagesender_close (message_sender=0x555555b60860) at uamqp/src/message_sender.c:846 messagesender_destroy (message_sender=0x555555b60860) at uamqp/src/message_sender.c:795 destroy_event_sender (instance=0x5555556c74f0) at iothub_client/src/iothubtransport_amqp_telemetry_messenger.c:362 telemetry_messenger_stop (messenger_handle=0x5555556c74f0) at iothub_client/src/iothubtransport_amqp_telemetry_messenger.c:1666

causes this error message:

Error: Time:Wed Jan 10 20:37:31 2024 File:/home/ewertons/code/s1/azure-iot-sdk-c/uamqp/src/amqpvalue.c Func:amqpvalue_get_list_item_count Line:1345 Bad arguments: value = (nil), size = 0x1ffefff968

Because indicate_all_messages_as_error passes NULL for delivery_state.

# 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

Please see commit description above.

Description of the solution

Please see commit description above.