whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.19k stars 221 forks source link

minor issue in mqtt.subscribe #11

Closed loboris closed 7 years ago

loboris commented 7 years ago

Mqtt subscribe causes the panic:

/ > mq:subscribe("test",0,mqmsg)
Guru Meditation Error of type LoadProhibited occurred on core  0. Exception was unhandled.
Register dump:
....

The source of the error is to small alocated memory for topic string in add_subs_callback function. It is necessary to change: callback->topic = (char *)malloc(strlen(topic)); to callback->topic = (char *)malloc(strlen(topic)+1);

With that change subscribe function works as expected.

jolivepetrus commented 7 years ago

Thanks for report this. This is solved in https://github.com/whitecatboard/Lua-RTOS-ESP32/commit/8b02d923db97f185330ebfb170fa162bfc5fc56d.