• Bug#164753: This patch introduces a memory leak

    From Johan Walles@1:229/2 to All on Mon Aug 16 10:40:08 2004
    From: [email protected]

    If you've more than one network interface, this patch will introduce a
    memory leak.

    Let's say you have two interfaces, eth0 and eth1. Nothing is in the
    list to begin with. The first time you do forcedFindInterface(eth0),
    eth0 will be added to the list. Then you ask for eth1. Eth1 is added
    to the list, and eth0 gets leaked.

    This is repeated each time network status is updated, which is twice
    per second if I remember correctly. So if you have n network cards,
    the leak will be:

    (2 * (n - 1) * sizeof(interface)) bytes per second.

    After staring at my code some more, I think the real problem lies in netload_receiveUpdates():

    1 for (prev = interfaces, iter = interfaces->next;
    2 iter != NULL;
    3 prev = iter, iter = iter->next)
    4 {
    5 if (!iter->isAlive)
    6 {
    7 prev->next = iter->next;
    8 free(iter->name);
    9 free(iter);
    0 iter = prev->next;
    1 }
    2 }

    iter can become NULL on line 10. Then NULL is dereferenced at line 3.
    A NULL check and a break statement is required after line 10.

    Cheers //Johan

    PS: Eric, I can't guarantee I'll release a new version soonish, so a
    Debian specific patch is probably better than waiting for me...


    ----------------------------------------------
    Mailblocks - A Better Way to Do Email
    http://about.mailblocks.com/info



    --
    To UNSUBSCRIBE, email to [email protected]
    with a subject of "unsubscribe". Trouble? Contact [email protected]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)