RFR: JDK-8261601: free memory in early return in Java_sun_nio_ch_sctp_SctpChannelImpl_receive0

Matthias Baesken mbaesken at openjdk.java.net
Fri Feb 12 08:54:45 UTC 2021


There seems to be an early return in Java_sun_nio_ch_sctp_SctpChannelImpl_receive0 that misses freeing memory.

Sonar reports :
https://sonarcloud.io/project/issues?id=shipilev_jdk&languages=c&open=AXck8Cl0BBG2CXpcnjFu&resolved=false&severities=BLOCKER&types=BUG

Potential leak of memory pointed to by 'newBuf'
I adjusted  the early return and added freeing memory .


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 ?

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

Commit messages:
 - JDK-8261601

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

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



More information about the security-dev mailing list