Fixed a possible crash

This commit is contained in:
WolverinDEV 2020-12-16 19:46:33 +01:00
parent e80afb1145
commit 6605a440bd
1 changed files with 5 additions and 4 deletions

View File

@ -62,6 +62,9 @@ void PacketEncoder::send_packet(ts::protocol::OutgoingServerPacket *packet) {
packet->set_packet_id(full_id & 0xFFFFU);
packet->generation = full_id >> 16U;
auto category = stats::ConnectionStatistics::category::from_type(packet->packet_type());
this->callback_connection_stats(this->callback_data, category, packet->packet_length() + 96); /* 96 for the UDP packet overhead */
{
std::lock_guard qlock{this->write_queue_mutex};
*this->encrypt_queue_tail = packet;
@ -69,9 +72,6 @@ void PacketEncoder::send_packet(ts::protocol::OutgoingServerPacket *packet) {
}
this->callback_request_write(this->callback_data);
auto category = stats::ConnectionStatistics::category::from_type(packet->packet_type());
this->callback_connection_stats(this->callback_data, category, packet->packet_length() + 96); /* 96 for the UDP packet overhead */
}
void PacketEncoder::send_packet(protocol::PacketType type, protocol::PacketFlag::PacketFlags flag, const void *payload, size_t payload_size) {
@ -216,8 +216,9 @@ void PacketEncoder::send_command(const std::string_view &command, bool low, std:
}
this->callback_request_write(this->callback_data);
if(own_data_buffer)
if(own_data_buffer) {
::free(own_data_buffer_ptr);
}
}
void PacketEncoder::encrypt_pending_packets() {