BUG: use-after-free in Process::hide on Android

juce::Process::hide() in modules/juce_gui_basics/native/juce_Windowing_android.cpp frees a JNI local reference and then dereferences it:

LocalRef currentActivity (getCurrentActivity().get());

getCurrentActivity () returns a LocalRef <jobject> temporary which owns a JNI local reference.

LocalRef::get ()returns the owned jobject.

The local currentActivity is constructed adopting the local reference (now doubly-owned).

The temporary is destroyed and calls DeleteLocalRef with the owned jobject.

currentActivity now holds (and dereferences) a freed local reference.

Simply removing the call to get () resolves the problem.

NB: while banging on this, I hit scenarios where the current activity was null, so please also insert a conditional guarding against dereferencing a null return value from getCurrentActivity ().

It looks to me like this was already fixed in this commit which was included in JUCE 8.0.11:

Please try updating to the current develop branch and check whether the issues are still present.

Use-after-free was indeed resolved (sorry for the noise), but there is no check whether currentActivity is null or not. I have seen it null while testing.

To confirm, you’re testing with the develop branch?