1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 03:42:20 +01:00

[api] Fix crash with gcc compiler on host (#8902)

This commit is contained in:
Jesse Hills
2025-05-27 06:46:51 +12:00
committed by GitHub
parent 430f63fcbb
commit af7b1a3a23

View File

@@ -4,11 +4,11 @@
#include <cinttypes> #include <cinttypes>
#include <utility> #include <utility>
#include "esphome/components/network/util.h" #include "esphome/components/network/util.h"
#include "esphome/core/application.h"
#include "esphome/core/entity_base.h" #include "esphome/core/entity_base.h"
#include "esphome/core/hal.h" #include "esphome/core/hal.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/version.h" #include "esphome/core/version.h"
#include "esphome/core/application.h"
#ifdef USE_DEEP_SLEEP #ifdef USE_DEEP_SLEEP
#include "esphome/components/deep_sleep/deep_sleep_component.h" #include "esphome/components/deep_sleep/deep_sleep_component.h"
@@ -153,7 +153,11 @@ void APIConnection::loop() {
} else { } else {
this->last_traffic_ = App.get_loop_component_start_time(); this->last_traffic_ = App.get_loop_component_start_time();
// read a packet // read a packet
this->read_message(buffer.data_len, buffer.type, &buffer.container[buffer.data_offset]); if (buffer.data_len > 0) {
this->read_message(buffer.data_len, buffer.type, &buffer.container[buffer.data_offset]);
} else {
this->read_message(0, buffer.type, nullptr);
}
if (this->remove_) if (this->remove_)
return; return;
} }