LiamBindle / MQTT-C

A portable MQTT C client for embedded systems and PCs alike.
https://liambindle.ca/MQTT-C
MIT License
766 stars 269 forks source link

mqtt_publish return value causes mqtt_error_str when not connected #153

Open infn-ke opened 2 years ago

infn-ke commented 2 years ago

Invoking mqtt_publish without being in a connected state gives a negative return value. Passing this return value into mqtt_error_str causes a SEGV.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff756a35c in mqtt_error_str (error=-1094795586) at /usr/local/src/mqtt-c/src/mqtt.c:1773
1773            return MQTT_ERRORS_STR[offset];

Unfortunately MQTT_CLIENT_TRY_PACK is a macro so cannot get better backtrace without replacing it with a function.