[quagga-dev 10520] Re: ripd/rip_interface.c memleak from inappropriate strdup() calls
equinox at opensourcerouting.org
Fri May 3 16:02:54 BST 2013
On Wed, May 01, 2013 at 12:09:09AM +0000, Charlet, Ricky wrote:
> I'm new around these parts and just jumping into quagga code.
> During review, I believe I've spotted a few memory leaks in ripd/rip_interface.c. In several places, there are calls to stdlib.h's strdup() function. Memory returned from strdup() never seems to be free'd. For example:
> /* Add interface to rip_enable_if. */
> static int
> rip_enable_if_add (struct rip *rip, const char *ifname)
> int ret;
> ret = rip_enable_if_lookup (rip, ifname);
> if (ret >= 0)
> return -1;
> vector_set (rip->rip_enable_interface, strdup (ifname));
> rip_enable_apply_all (rip); /* TODOVJ */
> return 1;
> I'm just tossing this out as an FYI cause I've been wrong before (especially when I'm in a new code base). So will someone else put some eyeballs on that and see if you think those are true memleaks? And if they are not, I would love to be educated.
The vector_* functions perform array manipulation. The pointer is saved
to the rip->rip_enable_interface array and therefore not leaked at that
point. The free() is in the function directly below,
Admittedly, there is no error checking for strdup(), which could return
NULL if we're out of memory.
More information about the Quagga-dev