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-sdk version: 0.14.2
- Platform: iOS (arm64)
- React Native: 0.83.4
Bug Description
Tapping a
GMSMarkerwhosesnippetproperty isnilcauses a crash on iOS due to a null pointer dereference in_platform_strlen.Steps to Reproduce
snippet(only position, title, etc.).Crash Stack Trace
Root Cause
In
NavView.mm, bothhandleMarkerClick:andhandleMarkerInfoWindowTapped:pass[marker.snippet UTF8String]directly to astd::stringfield in the event struct.When
marker.snippetisnil(the default forGMSMarker), Objective-C nil messaging returnsNULLfromUTF8String. Thestd::string(const char*)constructor then callsstrlen(NULL), which is undefined behavior and crashes in_platform_strlen.marker.titleis already correctly guarded with a nil check on the lines above, butmarker.snippetis not:Suggested Fix
Add the same nil guard used for
titletosnippetin both methods: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