info: make a bit of code more defensive
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 1 May 2016 18:40:55 +0000 (20:40 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 1 May 2016 18:46:20 +0000 (20:46 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/info/olsrd_info.c

index b64744c..9dc6437 100644 (file)
@@ -517,12 +517,12 @@ static void send_info(const char * req, unsigned int send_what, int the_socket,
    * older replies that are still in-flight (since the send function
    * iterates from the start towards the end).
    */
-  send_index = MAX_CLIENTS - 1;
-  while (true) {
-    if (!outbuffer.buffer[send_index] || !send_index) {
+  send_index = MAX_CLIENTS;
+  while (send_index) {
+    send_index--;
+    if (!outbuffer.buffer[send_index]) {
       break;
     }
-    send_index--;
   }
   assert(send_index < MAX_CLIENTS);
   assert(!outbuffer.buffer[send_index]);