Skip to content

Commit abc2669

Browse files
authored
Fix NSNull crash in string encode (#5579)
* Fix NSNull crash in string encode * add changelog
1 parent 736d2ae commit abc2669

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
3+
- [fixed] Fixed a crash that could occur if certian plist fields necessary to create Crashlytics records were missing at runtime. Also added some diagnostic logging to make the issue cause more explicit (#5565).
4+
15
# v4.1.0
26

37
- [fixed] Fixed unchecked `malloc`s in Crashlytics (#5428).

Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,15 @@ - (google_crashlytics_Platforms)protoPlatformFromString:(NSString *)str {
219219
}
220220

221221
/** Mallocs a pb_bytes_array and copies the given NSString's bytes into the bytes array.
222-
* @note Memory needs to be free manually, through pb_free or pb_release.
222+
* @note Memory needs to be freed manually, through pb_free or pb_release.
223223
* @param string The string to encode as pb_bytes.
224224
*/
225225
pb_bytes_array_t *FIRCLSEncodeString(NSString *string) {
226+
if ([string isMemberOfClass:[NSNull class]]) {
227+
FIRCLSErrorLog(@"Expected encodable string, but found NSNull instead. "
228+
@"Set a symbolic breakpoint at FIRCLSEncodeString to debug.");
229+
string = nil;
230+
}
226231
NSString *stringToEncode = string ? string : @"";
227232
NSData *stringBytes = [stringToEncode dataUsingEncoding:NSUTF8StringEncoding];
228233
return FIRCLSEncodeData(stringBytes);

0 commit comments

Comments
 (0)