RFR: 8304290: Some JNI calls made without checking exceptions in media
Michael Strauß
mstrauss at openjdk.org
Mon Apr 24 05:55:57 UTC 2023
On Tue, 18 Apr 2023 02:08:03 GMT, Alexander Matveev <almatvee at openjdk.org> wrote:
> - Added missing exception checks for JNI calls.
> - Improved JNI error checking by checking for both exception and return value.
> - Minor code clean up.
modules/javafx.media/src/main/native/jfxmedia/jni/Logger.cpp line 130:
> 128: // Get global reference
> 129: m_cls = (jclass)pEnv->NewWeakGlobalRef(local_cls);
> 130: pEnv->DeleteLocalRef(local_cls);
What is this code attempting to do? After `local_cls` is deleted, `m_cls` refers to a potentially freed object and is thus not safe to use. In order to do anything meaningful with `m_cls`, a strong reference needs to be acquired with `NewLocalRef(m_cls)`.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1094#discussion_r1174812607
More information about the openjfx-dev
mailing list