From d13134135bfde3cf2ddbc5f8df890737a83516f1 Mon Sep 17 00:00:00 2001 From: Maurice Makaay Date: Tue, 12 Oct 2021 13:51:41 +0200 Subject: [PATCH] Fix LoadProhibited crash for logger baud_rate 0 (#2498) Co-authored-by: Maurice Makaay --- esphome/components/logger/logger.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 4352b7e208..2d85969bf3 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -111,14 +111,15 @@ void HOT Logger::log_message_(int level, const char *tag, int offset) { this->set_null_terminator_(); const char *msg = this->tx_buffer_ + offset; + if (this->baud_rate_ > 0) { #ifdef USE_ARDUINO - if (this->baud_rate_ > 0) this->hw_serial_->println(msg); #endif // USE_ARDUINO #ifdef USE_ESP_IDF - uart_write_bytes(uart_num_, msg, strlen(msg)); - uart_write_bytes(uart_num_, "\n", 1); + uart_write_bytes(uart_num_, msg, strlen(msg)); + uart_write_bytes(uart_num_, "\n", 1); #endif + } #ifdef USE_ESP32 // Suppress network-logging if memory constrained, but still log to serial