RFR: 8205342: windows : potential memleaks in getAdapter(s) in NetworkInterface_winXP.c
Thomas Stüfe
thomas.stuefe at gmail.com
Wed Jun 20 08:25:30 UTC 2018
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