diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-30 14:43:32 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-30 14:43:32 -0400 |
commit | bd695135dcb9220e6a75e48975dd8473d3d1fcbe (patch) | |
tree | ca183e6f71124030395f74331391e50cf414bc3c /core | |
parent | 77fa38f597305195d50c6674150365a601c30add (diff) |
Fixed segfault.
Diffstat (limited to 'core')
-rw-r--r-- | core/Lossless_UDP.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index eb1314d1..6be8328f 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c | |||
@@ -308,12 +308,16 @@ IP_Port connection_ip(int connection_id) | |||
308 | /* returns the number of packets in the queue waiting to be successfully sent. */ | 308 | /* returns the number of packets in the queue waiting to be successfully sent. */ |
309 | uint32_t sendqueue(int connection_id) | 309 | uint32_t sendqueue(int connection_id) |
310 | { | 310 | { |
311 | if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) | ||
312 | return 0; | ||
311 | return connections[connection_id].sendbuff_packetnum - connections[connection_id].successful_sent; | 313 | return connections[connection_id].sendbuff_packetnum - connections[connection_id].successful_sent; |
312 | } | 314 | } |
313 | 315 | ||
314 | /* returns the number of packets in the queue waiting to be successfully read with read_packet(...) */ | 316 | /* returns the number of packets in the queue waiting to be successfully read with read_packet(...) */ |
315 | uint32_t recvqueue(int connection_id) | 317 | uint32_t recvqueue(int connection_id) |
316 | { | 318 | { |
319 | if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) | ||
320 | return 0; | ||
317 | return connections[connection_id].recv_packetnum - connections[connection_id].successful_read; | 321 | return connections[connection_id].recv_packetnum - connections[connection_id].successful_read; |
318 | } | 322 | } |
319 | 323 | ||
@@ -321,6 +325,8 @@ uint32_t recvqueue(int connection_id) | |||
321 | return -1 if no packet in queue */ | 325 | return -1 if no packet in queue */ |
322 | char id_packet(int connection_id) | 326 | char id_packet(int connection_id) |
323 | { | 327 | { |
328 | if (connection_id < 0 || connection_id >= MAX_CONNECTIONS) | ||
329 | return -1; | ||
324 | if (recvqueue(connection_id) != 0 && connections[connection_id].status != 0) | 330 | if (recvqueue(connection_id) != 0 && connections[connection_id].status != 0) |
325 | return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0]; | 331 | return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0]; |
326 | return -1; | 332 | return -1; |