Skip to content

Commit

Permalink
Prevent keyed archiver encoding crashes when writing read receipts to…
Browse files Browse the repository at this point in the history
… the file store
  • Loading branch information
stefanceriu committed Aug 22, 2023
1 parent 2adb8c2 commit 42a57e0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,23 @@ - (void)saveReceipts

// Store new data
[self checkFolderExistenceForRoom:roomId forBackup:NO];
[NSKeyedArchiver archiveRootObject:receiptsStore toFile:file];

NSError *error = nil;
NSData *result = [NSKeyedArchiver archivedDataWithRootObject:receiptsStore requiringSecureCoding:false error:&error];

if (error != nil)
{
MXLogErrorDetails(@"Failed archiving receipts store", error);
continue;
}

[result writeToURL:[NSURL fileURLWithPath:file] options: NSDataWritingAtomic error: &error];

if (error != nil)
{
MXLogErrorDetails(@"Failed writing receipts store to file", error);
continue;
}
}
}
}
Expand Down

0 comments on commit 42a57e0

Please sign in to comment.