JBR-9580 Fix crash in [MenuAccessibility accessibilityChildren]

* Add null checks for variables that can have null values to prevent hard crash
* Add missing CHECK_EXCEPTION after JNI call
* Add missing DeleteLocalRef for axComponent

(cherry picked from commit 96fcd9e591)
This commit is contained in:
Dmitry Drobotov
2025-11-07 12:39:13 +01:00
committed by jbrbot
parent 1fde6c7cc0
commit 511efb0b42

View File

@@ -67,6 +67,10 @@ static jclass sjc_CAccessibility = NULL;
jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
sjm_getCurrentAccessiblePopupMenu,
fAccessible, fComponent);
CHECK_EXCEPTION();
if (axComponent == NULL) {
return nil;
}
CHECK_EXCEPTION();
if (axComponent == nil) {
@@ -75,6 +79,10 @@ static jclass sjc_CAccessibility = NULL;
CommonComponentAccessibility *currentElement = [CommonComponentAccessibility createWithAccessible:axComponent
withEnv:env withView:self->fView isCurrent:YES];
(*env)->DeleteLocalRef(env, axComponent);
if (currentElement == nil) {
return nil;
}
NSArray *children = [CommonComponentAccessibility childrenOfParent:currentElement
withEnv:env