Fix double free on enet packet

main
Cameron Murphy Reikes 2 years ago
parent b6d1006860
commit ac1be560d2

@ -610,7 +610,7 @@ frame(void)
ENetPacket* packet = enet_packet_create((void*)&client_to_server, ENetPacket* packet = enet_packet_create((void*)&client_to_server,
sizeof(client_to_server), sizeof(client_to_server),
ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT); ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT);
enet_peer_send(peer, 0, packet); enet_peer_send(peer, 0, packet); // @Robust error check this
last_input_sent_time = time; last_input_sent_time = time;
} }
} }

@ -248,8 +248,8 @@ void server(void* data)
#endif #endif
//ENetPacket* gamestate_packet = enet_packet_create((void*)bytes_buffer, len, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT); //ENetPacket* gamestate_packet = enet_packet_create((void*)bytes_buffer, len, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT);
ENetPacket* gamestate_packet = enet_packet_create((void*)compressed_buffer, compressed_len, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT); ENetPacket* gamestate_packet = enet_packet_create((void*)compressed_buffer, compressed_len, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT);
// @Robust error check this
enet_peer_send(&server->peers[i], 0, gamestate_packet); enet_peer_send(&server->peers[i], 0, gamestate_packet);
enet_packet_destroy(gamestate_packet);
free(bytes_buffer); free(bytes_buffer);
free(compressed_buffer); free(compressed_buffer);
} }

Loading…
Cancel
Save