[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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
if (buffer.data_len > 0) {
this->read_message(buffer.data_len, buffer.type, &buffer.container[buffer.data_offset]); 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;
} }