RFR: 8362889: [GCC static analyzer] leak in libstringPlatformChars.c
Roger Riggs
rriggs at openjdk.org
Mon Jul 21 15:29:26 UTC 2025
On Mon, 21 Jul 2025 14:12:55 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
> This is reported by the gcc static analyzer (-fanalyzer); it is just test coding so not very critical but probably should still be adjusted .
>
>
> /jdk/test/jdk/java/lang/String/nativeEncoding/libstringPlatformChars.c:74:12: warning: leak of 'str' [CWE-401] [-Wanalyzer-malloc-leak]
> 74 | return JNU_NewStringPlatform(env, str);
test/jdk/java/lang/String/nativeEncoding/libstringPlatformChars.c line 74:
> 72: (*env)->ReleasePrimitiveArrayCritical(env, bytes, (void*)jbytes, 0);
> 73:
> 74: jstring res = JNU_NewStringPlatform(env, str);
At line 66: where it returns null, it seem like it should also be freeing `str`. (The analyzer didn't catch that?)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26415#discussion_r2219548259
More information about the core-libs-dev
mailing list