add return to faile_message, avoid segment fault

should not use response_topic when calloc failed
This commit is contained in:
Ss Wang
2024-01-30 11:50:01 +08:00
committed by Euripedes Rocha
parent fd21b27a83
commit 37478a9c00

View File

@ -761,7 +761,7 @@ mqtt_message_t *mqtt5_msg_publish(mqtt_connection_t *connection, const char *top
char *response_topic = calloc(1, response_topic_size);
if (!response_topic) {
ESP_LOGE(TAG, "Failed to calloc %d memory", response_topic_size);
fail_message(connection);
return fail_message(connection);
}
snprintf(response_topic, response_topic_size, "%s/%s", property->response_topic, resp_info);
if (append_property(connection, MQTT5_PROPERTY_RESPONSE_TOPIC, 2, response_topic, response_topic_size) == -1) {