mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
removed potential segfault
This commit is contained in:
parent
a164c15c00
commit
7097349552
|
@ -393,7 +393,10 @@ uint32_t recvqueue(int connection_id)
|
|||
return -1 if no packet in queue */
|
||||
char id_packet(int connection_id)
|
||||
{
|
||||
if (recvqueue(connection_id) > 0 && connections[connection_id].status != 0 && connection_id < MAX_CONNECTIONS)
|
||||
if (connection_id < 0 || connection_id >= MAX_CONNECTIONS)
|
||||
return -1;
|
||||
|
||||
if (recvqueue(connection_id) != 0 && connections[connection_id].status != 0)
|
||||
return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0];
|
||||
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user