diff options
author | rlt3 <leroy@bythehilt.com> | 2013-08-01 17:52:17 -0400 |
---|---|---|
committer | rlt3 <leroy@bythehilt.com> | 2013-08-01 17:52:17 -0400 |
commit | 7097349552aa9c8262728a115241fa2358e87c58 (patch) | |
tree | c2975894e5ae0b52fbb64580be863fd79c75aca7 | |
parent | a164c15c00d7279faa6c8b835137640cc8ab7af0 (diff) |
removed potential segfault
-rw-r--r-- | core/Lossless_UDP.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) | |||
393 | return -1 if no packet in queue */ | 393 | return -1 if no packet in queue */ |
394 | char id_packet(int connection_id) | 394 | char id_packet(int connection_id) |
395 | { | 395 | { |
396 | if (recvqueue(connection_id) > 0 && connections[connection_id].status != 0 && connection_id < MAX_CONNECTIONS) | 396 | if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) |
397 | return -1; | ||
398 | |||
399 | if (recvqueue(connection_id) != 0 && connections[connection_id].status != 0) | ||
397 | return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0]; | 400 | return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0]; |
398 | 401 | ||
399 | return -1; | 402 | return -1; |