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

Matthias Baesken mbaesken at openjdk.java.net
Tue Feb 16 08:45:40 UTC 2021


On Fri, 12 Feb 2021 08:50:14 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> 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 ?

This pull request has now been integrated.

Changeset: cdc874d4
Author:    Matthias Baesken <mbaesken at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/cdc874d4
Stats:     2 lines in 1 file changed: 1 ins; 0 del; 1 mod

8261601: free memory in early return in Java_sun_nio_ch_sctp_SctpChannelImpl_receive0

Reviewed-by: clanger, dfuchs, bpb

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

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



More information about the security-dev mailing list