Skip to content

Commit

Permalink
Check for null before calling strdup
Browse files Browse the repository at this point in the history
Fixes crash on iOS when calling OneSignal.User.PushSubscription.Id or OneSignal.User.PushSubscription.Token when vales are null. strdup only accounts for string parameters and not null
  • Loading branch information
shepherd-l authored and jinliu9508 committed Feb 27, 2024
1 parent 18c7028 commit 051877e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,16 @@ void _oneSignalUserRemoveTags(const char* tagsJson) {
}

const char* _oneSignalPushSubscriptionGetId() {
if (OneSignal.User.pushSubscription.id == NULL) {
return NULL;
}
return strdup([OneSignal.User.pushSubscription.id UTF8String]);
}

const char* _oneSignalPushSubscriptionGetToken() {
if (OneSignal.User.pushSubscription.token == NULL) {
return NULL;
}
return strdup([OneSignal.User.pushSubscription.token UTF8String]);
}

Expand Down

0 comments on commit 051877e

Please sign in to comment.