From 7097349552aa9c8262728a115241fa2358e87c58 Mon Sep 17 00:00:00 2001 From: rlt3 Date: Thu, 1 Aug 2013 17:52:17 -0400 Subject: removed potential segfault --- core/Lossless_UDP.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index 014f0014..4affc38f 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c @@ -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; -- cgit v1.2.3