fix #598 don't corrupt the heap when a TCP connection drops

This commit is contained in:
Kevin Hester
2020-12-27 16:58:32 +08:00
parent c06b7b2b48
commit c972197643
4 changed files with 38 additions and 14 deletions

View File

@@ -7,22 +7,27 @@
#include <assert.h>
#if FromRadio_size > MAX_TO_FROM_RADIO_SIZE
#error FromRadio is too big
#error FromRadio is too big
#endif
#if ToRadio_size > MAX_TO_FROM_RADIO_SIZE
#error ToRadio is too big
#error ToRadio is too big
#endif
PhoneAPI::PhoneAPI()
{
}
PhoneAPI::PhoneAPI() {}
void PhoneAPI::init()
{
observe(&service.fromNumChanged);
}
void PhoneAPI::close() {
unobserve();
state = STATE_SEND_NOTHING;
isConnected = false;
onConnectionChanged(isConnected);
}
void PhoneAPI::checkConnectionTimeout()
{
if (isConnected) {
@@ -102,7 +107,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
if (!available()) {
// DEBUG_MSG("getFromRadio, !available\n");
return 0;
}
}
DEBUG_MSG("getFromRadio, state=%d\n", state);
@@ -170,7 +175,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
if (packetForPhone) {
printPacket("phone downloaded packet", packetForPhone);
// Encapsulate as a FromRadio packet
fromRadioScratch.which_variant = FromRadio_packet_tag;
fromRadioScratch.variant.packet = *packetForPhone;