iphlapi: Fix some leaks (coverity)

Juan Lang juan.lang at gmail.com
Tue Nov 6 11:54:26 CST 2012


Hi Frédéric,

thanks for the patch. Allow me to elaborate:

On Tue, Nov 6, 2012 at 6:05 AM, Alexandre Julliard <julliard at winehq.org>wrote:

> Frédéric Delanoy <frederic.delanoy at gmail.com> writes:
>
> > @@ -1520,8 +1521,8 @@ DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE
> pIpAddrTable, PULONG pdwSize, BOOL
> >             sizeof(MIB_IPADDRROW), IpAddrTableSorter);
> >          ret = NO_ERROR;
> >        }
> > -      HeapFree(GetProcessHeap(), 0, table);
> >      }
> > +    HeapFree(GetProcessHeap(), 0, table);
> >    }
>
> That's not the correct fix.
>

The correct place to fix is getIpAddrTable in ifenum.c, so that should it
fail, it frees the memory it allocated. This was obviously an oversight on
my part. See the for loop here:
http://source.winehq.org/source/dlls/iphlpapi/ifenum.c#L735

This loop terminates if something fails, so after the for loop is an ideal
place to add a HeapFree. In this way, the callers (GetIpAddrTable is but
one) never have to cope with freeing memory when getIpAddrTable fails.
--Juan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20121106/68798234/attachment.html>


More information about the wine-devel mailing list