RFR: JDK-8261791: handleSendFailed in SctpChannelImpl.c potential leaks

Matthias Baesken mbaesken at openjdk.java.net
Tue Feb 16 12:31:46 UTC 2021


In another bug  this question from m  was answered by  Alan Bateman :
--------------------------------
Btw. while adjusting Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 , I started to wonder what happens to the allocated memory in the same file in handleSendFailed ( if ((addressP = malloc(dataLength)) == NULL) ) in early return cases incl. the CHECK_NULL , is there some deallocation missing there too ?
--------------------------------
Yes, the error paths in handleSendFailed should be looked at. If NewDirectByteBuffer or recvmsg fails then addressP needs to be freed. Furthermore, if the NewObject fails and bufferObj != NULL then the memory for the direct buffer will need to be freed too (as JNI NewDirectByteBuffer does not setup a cleaner).
--------------------------------

So I added freeing of the malloced memory to handleSendFailed .
Please review !

Thanks, Matthias

-------------

Commit messages:
 - JDK-8261791

Changes: https://git.openjdk.java.net/jdk/pull/2586/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2586&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8261791
  Stats: 10 lines in 1 file changed: 8 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2586.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2586/head:pull/2586

PR: https://git.openjdk.java.net/jdk/pull/2586



More information about the security-dev mailing list