On Fri, 16 Oct 2026 08:55:58 GMT, Matthias Baesken <[email protected]> wrote:

> The gcc static analyzer reports this issue :
> 
> `jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c:1195:1: 
> warning: leak of 'asd.configs' [CWE-401] [-Wanalyzer-malloc-leak]`
> 
> In Java_sun_awt_X11GraphicsConfig_init(JNIEnv *env, jobject this, jint 
> visualNum, jint screen)
> we have this coding
> 
> 
>     AwtScreenData asd = x11Screens[screen];
>     ...
>     if (asd.numConfigs == 0) {
>         getAllConfigs(env, screen, &asd); // line 1163 — seems we fill the 
> 'local copy' asd only
>     }
> 
> 
> So at the end of function Java_sun_awt_X11GraphicsConfig_init, the leask of 
> some asd field is reported.
> (maybe we do not call these init methods very often, so it might be a rare 
> issue)
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

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

> 1154: 
> 1155:     AwtGraphicsConfigData *adata = NULL;
> 1156:     AwtScreenData *asd = &x11Screens[screen];

I do not understand how this changes anything ...

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

> 1189:                              adata->awt_visInfo.visual,
> 1190:                              depth, ZPixmap, 0, NULL, 1, 1, 32, 0);
> 1191:     if (tempImage == NULL) {

whilst throwing an exception is better than a crash, why did you decide to 
throw rather than just return.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33405#discussion_r4299477901
PR Review Comment: https://git.openjdk.org/jdk/pull/33405#discussion_r4299474931

Reply via email to