diff --git a/Bugsnag/BSGOutOfMemoryWatchdog.m b/Bugsnag/BSGOutOfMemoryWatchdog.m index 375914f23..8eff738e0 100644 --- a/Bugsnag/BSGOutOfMemoryWatchdog.m +++ b/Bugsnag/BSGOutOfMemoryWatchdog.m @@ -274,17 +274,19 @@ - (NSDictionary *)readSentinelFile { bsg_log_err(@"Failed to read oom watchdog file: %@", error); return nil; } - NSDictionary *contents = [BSGJSONSerialization JSONObjectWithData:data options:0 error:&error]; + NSMutableDictionary *contents = [[BSGJSONSerialization JSONObjectWithData:data options:0 error:&error] mutableCopy]; if (error) { bsg_log_err(@"Failed to read oom watchdog file: %@", error); return nil; } + NSMutableDictionary *app = [contents[BSGKeyApp] mutableCopy]; // Override JSON data with KV store data - contents[BSGKeyApp][APP_KEY_IS_MONITORING_OOM] = [self.kvStore NSBooleanForKey:KV_KEY_IS_MONITORING_OOM defaultValue:false]; - contents[BSGKeyApp][APP_KEY_IS_ACTIVE] = [self.kvStore NSBooleanForKey:KV_KEY_IS_ACTIVE defaultValue:false]; - contents[BSGKeyApp][APP_KEY_IS_IN_FOREGROUND] = [self.kvStore NSBooleanForKey:KV_KEY_IS_IN_FOREGROUND defaultValue:false]; - contents[BSGKeyDevice][DEVICE_KEY_LAST_LOW_MEMORY_WARNING] = [self.kvStore stringForKey:KV_KEY_LAST_LOW_MEMORY_WARNING defaultValue:@""]; + app[APP_KEY_IS_MONITORING_OOM] = [self.kvStore NSBooleanForKey:KV_KEY_IS_MONITORING_OOM defaultValue:false]; + app[APP_KEY_IS_ACTIVE] = [self.kvStore NSBooleanForKey:KV_KEY_IS_ACTIVE defaultValue:false]; + app[APP_KEY_IS_IN_FOREGROUND] = [self.kvStore NSBooleanForKey:KV_KEY_IS_IN_FOREGROUND defaultValue:false]; + app[DEVICE_KEY_LAST_LOW_MEMORY_WARNING] = [self.kvStore stringForKey:KV_KEY_LAST_LOW_MEMORY_WARNING defaultValue:@""]; + contents[BSGKeyApp] = app; return contents; }