Opened 4 years ago

Last modified 2 years ago

#851 new Bug / Defect

Memory leakage

Reported by: laowei Owned by:
Priority: major Milestone:
Component: Generic / unclassified Version: OpenVPN git master branch (Community Ed)
Severity: Not set (select this one, unless your'e a OpenVPN developer) Keywords:
Cc: plai

Description

In init.c file, line 1577, if c->c1.tuntap is not NULL, the code doesn't free the memory. do_init_tun will alloc new memory for c->c1.tuntap.

#ifdef TARGET_ANDROID
    /* If we emulate persist-tun on android we still have to open a new tun and
     * then close the old */
    int oldtunfd = -1;
    if (c->c1.tuntap)
    {
        oldtunfd = c->c1.tuntap->fd;
    }
#endif

    /* initialize (but do not open) tun/tap object */
    do_init_tun(c);

Change History (4)

comment:1 Changed 4 years ago by Gert Döring

Cc: plai added

this is only relevant on TARGET_ANDROID, as for #ifndef TARGET_ANDROID, that whole branch is conditional on

    if (!c->c1.tuntap)
    {

... so maybe just free()ing inside the #ifdef block above? @plai?

comment:2 Changed 4 years ago by laowei

Yes. It is only relevant on TARGET_ANDROID.

comment:3 Changed 2 years ago by plaisthos

I am just looking again on this since I am not sure if this was fixed or not.

I am not sure what would not be freed in that case. And the current code around oldtunfd is a different but I also see no memory leak there. Keep in mind that fd is just an int and need to special free() call to release the memory.

comment:4 Changed 2 years ago by plaisthos

Sorry misread where the leak is going to happen. I am preparing a patch for this.

Note: See TracTickets for help on using tickets.