mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Android Accessibility: Guard app context calls in a few places to prevent potential nullptr dereferences
This commit is contained in:
parent
3739fe4829
commit
dd08be6215
1 changed files with 19 additions and 6 deletions
|
|
@ -250,6 +250,10 @@ public:
|
|||
return;
|
||||
|
||||
auto* env = getEnv();
|
||||
auto appContext = getAppContext();
|
||||
|
||||
if (appContext.get() == nullptr)
|
||||
return;
|
||||
|
||||
{
|
||||
for (auto* child : accessibilityHandler.getChildren())
|
||||
|
|
@ -293,7 +297,7 @@ public:
|
|||
true);
|
||||
env->CallVoidMethod (info,
|
||||
AndroidAccessibilityNodeInfo.setPackageName,
|
||||
env->CallObjectMethod (getAppContext().get(),
|
||||
env->CallObjectMethod (appContext.get(),
|
||||
AndroidContext.getPackageName));
|
||||
env->CallVoidMethod (info,
|
||||
AndroidAccessibilityNodeInfo.setSource,
|
||||
|
|
@ -760,12 +764,16 @@ AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation() const
|
|||
static bool areAnyAccessibilityClientsActive()
|
||||
{
|
||||
auto* env = getEnv();
|
||||
auto appContext = getAppContext();
|
||||
|
||||
LocalRef<jobject> accessibilityManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService,
|
||||
javaString ("accessibility").get()));
|
||||
if (appContext.get() != nullptr)
|
||||
{
|
||||
LocalRef<jobject> accessibilityManager (env->CallObjectMethod (appContext.get(), AndroidContext.getSystemService,
|
||||
javaString ("accessibility").get()));
|
||||
|
||||
if (accessibilityManager != nullptr)
|
||||
return env->CallBooleanMethod (accessibilityManager.get(), AndroidAccessibilityManager.isEnabled);
|
||||
if (accessibilityManager != nullptr)
|
||||
return env->CallBooleanMethod (accessibilityManager.get(), AndroidAccessibilityManager.isEnabled);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -778,6 +786,10 @@ void sendAccessibilityEventImpl (const AccessibilityHandler& handler, int eventT
|
|||
if (const auto sourceView = getSourceView (handler))
|
||||
{
|
||||
auto* env = getEnv();
|
||||
auto appContext = getAppContext();
|
||||
|
||||
if (appContext.get() == nullptr)
|
||||
return;
|
||||
|
||||
LocalRef<jobject> event (env->CallStaticObjectMethod (AndroidAccessibilityEvent,
|
||||
AndroidAccessibilityEvent.obtain,
|
||||
|
|
@ -785,7 +797,8 @@ void sendAccessibilityEventImpl (const AccessibilityHandler& handler, int eventT
|
|||
|
||||
env->CallVoidMethod (event,
|
||||
AndroidAccessibilityEvent.setPackageName,
|
||||
env->CallObjectMethod (getAppContext().get(), AndroidContext.getPackageName));
|
||||
env->CallObjectMethod (appContext.get(),
|
||||
AndroidContext.getPackageName));
|
||||
|
||||
env->CallVoidMethod (event,
|
||||
AndroidAccessibilityEvent.setSource,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue