Crash fix (#87)

This commit is contained in:
Isaac 2022-05-11 13:50:40 +09:30 committed by GitHub
parent 2a6c0be1bd
commit 02b99d0443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -186,6 +186,10 @@ bool network_allow_unknown_local_index(enum PacketType packetType) {
}
void network_send_to(u8 localIndex, struct Packet* p) {
if (p == NULL) {
LOG_ERROR("no data to send");
return;
}
// sanity checks
if (gNetworkType == NT_NONE) { LOG_ERROR("network type error none!"); return; }
if (p->error) { LOG_ERROR("packet error!"); return; }
@ -272,6 +276,10 @@ void network_send_to(u8 localIndex, struct Packet* p) {
}
void network_send(struct Packet* p) {
if (p == NULL) {
LOG_ERROR("no data to send");
return;
}
// prevent errors during writing from propagating
if (p->writeError) {
LOG_ERROR("packet has write error: %u", p->packetType);