RFR: 8292214: Memory leak in getAllConfigs of awt_GraphicsEnv.c:386

Prasanta Sadhukhan psadhukhan at openjdk.org
Thu Sep 22 04:26:17 UTC 2022


On Wed, 21 Sep 2022 20:15:48 GMT, Alisen Chung <achung at openjdk.org> wrote:

> changed return to cleanup in getAllConfigs
> changed cleanup to loop thru and free all allocated memory adjacent to graphicsConfig pointer

src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c line 578:

> 576:             if (graphicsConfigs[i] != 0) {
> 577:                 free(graphicsConfigs[i]);
> 578:             }

It seems  `screenDataPtr->numConfigs` is updated only when `success = JNI_TRUE` and here we are checking if `success != JNI_TRUE` condition, so amnot sure if we will be getting the correct updated configs number.
I think condition should be `i< ind-1` which is updated before every allocation, but it should be verified.

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

PR: https://git.openjdk.org/jdk/pull/10378



More information about the client-libs-dev mailing list