Opened 8 years ago

Closed 23 months ago

#851 closed Bug / Defect (fixed)

Memory leakage

Reported by: laowei Owned by: plaisthos
Priority: major Milestone: release 2.5
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 (6)

comment:1 Changed 8 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 8 years ago by laowei

Yes. It is only relevant on TARGET_ANDROID.

comment:3 Changed 6 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 6 years ago by plaisthos

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

comment:5 Changed 23 months ago by flichtenheld

Owner: set to plaisthos
Status: newassigned

comment:6 Changed 23 months ago by flichtenheld

Milestone: release 2.5
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.