Changeset 143

Show
Ignore:
Timestamp:
07/05/04 23:34:44 (9 years ago)
Author:
aprilp
Message:

* Fixed an endless loop in client_list_delete

Location:
trunk/wifidog
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/ChangeLog

    r141 r143  
    11# $Header$ 
     22004-07-05 Philippe April <papril777@yahoo.com> 
     3    * Fixed an endless loop in client_list_delete 
     4 
    252004-06-10 Alexandre Carmel-Veilleux <acv@acv.ca> 
    36        * Added debugging to libhttpd so that httpdGetConnection() traces 
  • trunk/wifidog/src/client_list.c

    r136 r143  
    212212    ptr = firstclient; 
    213213 
    214     if (ptr == client) { 
     214    if (ptr == NULL) { 
     215        debug(LOG_ERR, "Node list empty!"); 
     216    } else if (ptr == client) { 
    215217        firstclient = ptr->next; 
    216218        _client_list_free_node(client); 
    217219    } else { 
    218         while (ptr->next != NULL && ptr != client) { 
    219             if (ptr->next == client) { 
    220                 ptr->next = client->next; 
    221                 _client_list_free_node(client); 
    222             } 
     220        /* Loop forward until we reach our point in the list. */ 
     221        while (ptr->next != NULL && ptr->next != client) { 
     222            ptr = ptr->next; 
    223223        } 
    224     } 
    225 } 
    226  
    227  
     224        /* If we reach the end before finding out element, complain. */ 
     225        if (ptr->next == NULL) { 
     226            debug(LOG_ERR, "Node to delete could not be found."); 
     227        /* Free element. */ 
     228        } else { 
     229            ptr->next = client->next; 
     230            _client_list_free_node(client); 
     231        } 
     232    } 
     233}