-
Notifications
You must be signed in to change notification settings - Fork 29
iOS crash: NULL pointer dereference in handleMarkerClick due to nil marker.snippet #559
Copy link
Copy link
Open
Description
Bug Description
Tapping a GMSMarker whose snippet property is nil causes a crash on iOS due to a null pointer dereference in _platform_strlen.
Steps to Reproduce
- Add a marker to the map without setting a
snippet(only position, title, etc.). - Tap the marker.
- App crashes.
Crash Stack Trace
Crashed: com.apple.main-thread
0 libsystem_platform.dylib _platform_strlen + 4
1 ApolloScooters std::__1::basic_string<char, ...>::basic_string(char const*) + 63
2 ApolloScooters -[NavView handleMarkerClick:] + 350 (NavView.mm:350)
3 ApolloScooters -[NavViewController mapView:didTapMarker:] + 311 (NavViewController.mm:311)
4 CoreFoundation ...
7 ApolloScooters -[GMSDelegateForward forwardInvocation:]
10 ApolloScooters -[GMSMapView didTapMarker:]
Root Cause
In NavView.mm, both handleMarkerClick: and handleMarkerInfoWindowTapped: pass [marker.snippet UTF8String] directly to a std::string field in the event struct.
When marker.snippet is nil (the default for GMSMarker), Objective-C nil messaging returns NULL from UTF8String. The std::string(const char*) constructor then calls strlen(NULL), which is undefined behavior and crashes in _platform_strlen.
marker.title is already correctly guarded with a nil check on the lines above, but marker.snippet is not:
// title — correctly guarded ✓
marker.title != nil ? [marker.title UTF8String] : "",
marker.opacity,
marker.rotation,
// snippet — NOT guarded ✗ → crash when nil
[marker.snippet UTF8String],Suggested Fix
Add the same nil guard used for title to snippet in both methods:
- [marker.snippet UTF8String],
+ marker.snippet != nil ? [marker.snippet UTF8String] : "",This needs to be applied in two places in NavView.mm:
handleMarkerInfoWindowTapped:(line ~337)handleMarkerClick:(line ~349)
Environment
@googlemaps/react-native-navigation-sdkversion: 0.14.2- Platform: iOS (arm64)
- React Native: 0.83.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels