RFR: 8365609: Null pointer dereference in src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c OGLBlitToSurfaceViaTexture()
Artem Semenov
asemenov at openjdk.org
Wed Aug 20 11:41:35 UTC 2025
On Fri, 15 Aug 2025 17:05:18 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
> > The pointer pf is dereferenced in line 324 without checking for nullptr, although earlier in line 274 the same pointer is checked for nullptr, which indicates that it can be null.
>
> It is better first to confirm whether this pointer can actually be NULL. If it cannot then remove the unnecessary earlier NULL check.
In the same file, line 551 calls OGLBlitToSurfaceViaTexture() from line 263, where NULL is passed in place of pf.
All other calls are fine.
Also, another function with a similar issue from the same file, OGLBlitSwToTexture() from line 396, is called with an existing pf.
It is not possible to remove the first check as you suggest…
Since that line calculates the value:
jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha);
I suggest keeping the NULL check for OGLBlitToSurfaceViaTexture() at line 263, while for OGLBlitSwToTexture() at line 396, the check can be replaced with an assert.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26799#issuecomment-3205854738
More information about the client-libs-dev
mailing list