Skip to content

Commit 17f1aeb

Browse files
authored
fix: Check valid JSON object before calling emitModuleTableUpdate
Fixes #228
1 parent 29575be commit 17f1aeb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ios/RNSentryEventEmitter.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ + (void)emitStoredEvent {
4747
}
4848

4949
+ (void)emitModuleTableUpdate:(NSDictionary *)moduleTable {
50+
if (![NSJSONSerialization isValidJSONObject:moduleTable]) {
51+
return;
52+
}
53+
NSError *error = nil;
5054
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:moduleTable
5155
options:0
52-
error:nil];
53-
[self postNotificationName:kModuleTable withPayload:[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]];
56+
error:&error];
57+
if (nil == error) {
58+
[self postNotificationName:kModuleTable withPayload:[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]];
59+
}
5460
}
5561

5662
+ (void)postNotificationName:(NSString *)name withPayload:(NSObject *)object {

0 commit comments

Comments
 (0)