Skip to content

Commit

Permalink
Merge pull request #1030 from pedro-nadolny/master
Browse files Browse the repository at this point in the history
Adds error handling for serialization failure in MPDB readRows
  • Loading branch information
jaredmixpanel authored Feb 26, 2025
2 parents e41b17f + d0bfc8c commit d24abab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/MPDB.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ - (NSArray *)readRows:(NSString *)persistenceType numRows:(NSInteger)numRows fla
int eId = sqlite3_column_int(selectStatement, 0);
NSError *error;
NSMutableDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:blob options:NSJSONReadingMutableContainers error:&error];
if (error) {
NSString* utf8BlobString = [[NSString alloc] initWithData:blob encoding:NSUTF8StringEncoding];
[self logSqlError:[NSString stringWithFormat:@"Serialization error in %@ for column blob %@", tableName, utf8BlobString]];
continue;
}
jsonObject[@"id"] = [NSNumber numberWithInt:eId];
[rows addObject:jsonObject];
rowsRead++;
Expand Down

0 comments on commit d24abab

Please sign in to comment.