-
Bug
-
Resolution: Fixed
-
P4
-
17
-
b11
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8263787 | 11.0.12 | Matthias Baesken | P4 | Resolved | Fixed | b01 |
In another bug we had this question from me, and comment from 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 the coding should be adjusted to remove potential leaks.
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 the coding should be adjusted to remove potential leaks.
- backported by
-
JDK-8263787 (sctp) handleSendFailed in SctpChannelImpl.c potential leaks
-
- Resolved
-
- relates to
-
JDK-8261601 (sctp) free memory in early return in Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
-
- Resolved
-
-
JDK-8261881 (sctp) SendFailed Notifications that call NewDirectByteBuffer should register a cleaner
-
- Open
-