Skip to content

Add null guard for mControllers in MapLibreMapFragment dialog handler #1523

@aaronbrethorst

Description

@aaronbrethorst

In MapLibreMapFragment.java, the negative button handler in createNoLocationDialog() iterates mapFragment.mControllers without a null check (line 1098):

for (MapModeController controller : mapFragment.mControllers) {

If the dialog is shown before setMapMode() initializes mControllers, this would NPE. In practice this is low risk since setMapMode() runs in initMap() before user-triggered dialogs, but a defensive null guard should be added for safety.

The same pattern exists in the Google flavor's BaseMapFragment — both should be fixed.

Fix:

if (mapFragment.mControllers != null) {
    for (MapModeController controller : mapFragment.mControllers) {
        controller.onLocation();
    }
}

Found during review of #1513.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions