Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8261791: (sctp) handleSendFailed in SctpChannelImpl.c potential leaks
Reviewed-by: chegar, alanb
  • Loading branch information
MBaesken committed Feb 17, 2021
1 parent 9ba2b71 commit a0658795cfdba369c9cef84c011123932519acfb
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c
@@ -229,7 +229,10 @@ void handleSendFailed
msg->msg_iovlen = 1;

bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
CHECK_NULL(bufferObj);
if (bufferObj == NULL) {
free(addressP);
return;
}

alreadyRead = read - dataOffset;
if (alreadyRead > 0) {
@@ -243,12 +246,14 @@ void handleSendFailed

if (remaining > 0) {
if ((rv = recvmsg(fd, msg, 0)) < 0) {
free(addressP);
handleSocketError(env, errno);
return;
}

if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
//TODO: assert false: "should not reach here";
free(addressP);
return;
}
// TODO: Set and document (in API) buffers position.
@@ -258,7 +263,10 @@ void handleSendFailed
/* create SendFailed */
resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
CHECK_NULL(resultObj);
if (resultObj == NULL) {
if (bufferObj != NULL) free(addressP);
return;
}
(*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
(*env)->SetIntField(env, resultContainerObj, src_typeID,
sun_nio_ch_sctp_ResultContainer_SEND_FAILED);

0 comments on commit a065879

Please sign in to comment.