1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-08 04:43:46 +01:00

Merge branch 'fix_double_move' into integration

This commit is contained in:
J. Nick Koston
2025-10-06 17:42:43 -05:00
2 changed files with 6 additions and 10 deletions

View File

@@ -182,9 +182,9 @@ APIError APINoiseFrameHelper::try_read_frame_() {
return APIError::BAD_DATA_PACKET; return APIError::BAD_DATA_PACKET;
} }
// reserve space for body // Reserve space for body
if (rx_buf_.size() != msg_size) { if (this->rx_buf_.size() != msg_size) {
rx_buf_.resize(msg_size); this->rx_buf_.resize(msg_size);
} }
if (rx_buf_len_ < msg_size) { if (rx_buf_len_ < msg_size) {
@@ -240,7 +240,6 @@ APIError APINoiseFrameHelper::state_action_() {
this->prologue_[old_size] = (uint8_t) (this->rx_buf_.size() >> 8); this->prologue_[old_size] = (uint8_t) (this->rx_buf_.size() >> 8);
this->prologue_[old_size + 1] = (uint8_t) this->rx_buf_.size(); this->prologue_[old_size + 1] = (uint8_t) this->rx_buf_.size();
std::memcpy(this->prologue_.data() + old_size + 2, this->rx_buf_.data(), this->rx_buf_.size()); std::memcpy(this->prologue_.data() + old_size + 2, this->rx_buf_.data(), this->rx_buf_.size());
this->rx_buf_.clear();
state_ = State::SERVER_HELLO; state_ = State::SERVER_HELLO;
} }
@@ -307,7 +306,6 @@ APIError APINoiseFrameHelper::state_action_() {
return handle_noise_error_(err, LOG_STR("noise_handshakestate_read_message"), return handle_noise_error_(err, LOG_STR("noise_handshakestate_read_message"),
APIError::HANDSHAKESTATE_READ_FAILED); APIError::HANDSHAKESTATE_READ_FAILED);
} }
this->rx_buf_.clear();
aerr = check_handshake_finished_(); aerr = check_handshake_finished_();
if (aerr != APIError::OK) if (aerr != APIError::OK)
@@ -419,7 +417,6 @@ APIError APINoiseFrameHelper::read_packet(ReadPacketBuffer *buffer) {
buffer->data_offset = 4; buffer->data_offset = 4;
buffer->data_len = data_len; buffer->data_len = data_len;
buffer->type = type; buffer->type = type;
this->rx_buf_.clear();
return APIError::OK; return APIError::OK;
} }
APIError APINoiseFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) { APIError APINoiseFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) {

View File

@@ -142,9 +142,9 @@ APIError APIPlaintextFrameHelper::try_read_frame_() {
} }
// header reading done // header reading done
// reserve space for body // Reserve space for body
if (rx_buf_.size() != rx_header_parsed_len_) { if (this->rx_buf_.size() != this->rx_header_parsed_len_) {
rx_buf_.resize(rx_header_parsed_len_); this->rx_buf_.resize(this->rx_header_parsed_len_);
} }
if (rx_buf_len_ < rx_header_parsed_len_) { if (rx_buf_len_ < rx_header_parsed_len_) {
@@ -214,7 +214,6 @@ APIError APIPlaintextFrameHelper::read_packet(ReadPacketBuffer *buffer) {
buffer->data_offset = 0; buffer->data_offset = 0;
buffer->data_len = this->rx_header_parsed_len_; buffer->data_len = this->rx_header_parsed_len_;
buffer->type = this->rx_header_parsed_type_; buffer->type = this->rx_header_parsed_type_;
this->rx_buf_.clear();
return APIError::OK; return APIError::OK;
} }
APIError APIPlaintextFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) { APIError APIPlaintextFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) {