mParticle / mparticle-apple-sdk

mParticle Apple SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash when accessing null value in MPIdentityApiRequest.customerId

tiwoc opened this issue · comments

MPIdentityApiRequest.customerId is declared as follows:

@property (nonatomic, strong, nullable) NSString *customerId;

However, if you set customerId = nil and then read the new value of customerId, you get NSNull.null back (instead of the expected nil). When done from Swift, this crashes the app with

-[NSNull _fastCStringContents:]: unrecognized selector sent to instance 0x7fff8062d1e0
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-5)..

because the contract of the method is violated: It doesn't return either nil or an instance of NSString but an instance of NSNull.

The same issue occurs with the email property.

Proposed fix: Return nil from -[MPIdentityApiRequest customerId] if the dictionary access returns NSNull.null. Do the same for email.

@tiwoc Thanks for the detailed report--we will take a look to try to get this resolved for you.

@tiwoc The fix for this is now released as 7.15.9