RFR: 8205342: windows : potential memleaks in getAdapter(s) in NetworkInterface_winXP.c

Baesken, Matthias matthias.baesken at sap.com
Wed Jun 20 09:05:17 UTC 2018


Hi Thomas, I considered it but then I thought that the coding gets a bit simpler with a fix buffer .

Best regards, Matthias

> -----Original Message-----
> From: Thomas Stüfe [mailto:thomas.stuefe at gmail.com]
> Sent: Mittwoch, 20. Juni 2018 10:26
> To: Baesken, Matthias <matthias.baesken at sap.com>
> Cc: net-dev at openjdk.java.net
> Subject: Re: RFR: 8205342: windows : potential memleaks in getAdapter(s) in
> NetworkInterface_winXP.c
> 
> Hi Matthias,
> 
> thanks, good catch about the leak.
> 
> But could you not just simply free the error_msg_buf after the call to
> JNU_ThrowByName?
> 
> JNU_ThrowByName copies the message string, so no need to keep it alive
> afterwards:
> 
> diff -r e810abb27deb
> src/java.base/windows/native/libnet/NetworkInterface_winXP.c
> --- a/src/java.base/windows/native/libnet/NetworkInterface_winXP.c
>  Wed Jun 20 06:51:39 2018 +0200
> +++ b/src/java.base/windows/native/libnet/NetworkInterface_winXP.c
>  Wed Jun 20 10:21:57 2018 +0200
> @@ -138,6 +138,7 @@
>                      JNU_ThrowByName(env, "java/lang/Error",
>                          "IP Helper Library GetAdaptersAddresses
> function failure");
>                  }
> +                free(error_msg_buf);
>              } else {
>                  JNU_ThrowByName(env, "java/lang/Error",
>                      "IP Helper Library GetAdaptersAddresses function failed");
> 
> Thanks, Thomas
> 
> 
> 
> On Wed, Jun 20, 2018 at 10:07 AM, Baesken, Matthias
> <matthias.baesken at sap.com> wrote:
> > Hello . Please review this small  fix that  fixes  potential  memory leaks
> > in   getAdapter(s) in NetworkInterface_winXP.c  and simplifies the coding a
> > bit too .
> >
> > Currently   when generating error messages ,   some memory  is malloc-ed
> > for the error messages , but not always freed .
> >
> >
> >
> >
> >
> > Bug:
> >
> >
> >
> > https://bugs.openjdk.java.net/browse/JDK-8205342
> >
> >
> >
> > webrev :
> >
> >
> >
> > http://cr.openjdk.java.net/~mbaesken/webrevs/8205342/
> >
> >
> >
> >
> >
> > Thanks, Matthias
> >
> >
> >
> >


More information about the net-dev mailing list