Repository: firebase/firebase-ios-sdk
File: Crashlytics/Crashlytics/Components/FIRCLSUserLogging.m (Objective-C)

Code before:
  if (!FIRCLSIsValidPointer(storage) || !FIRCLSIsValidPointer(counter)) {
    FIRCLSSDKLogError("Bad parameters\n");
    return;
  }

  if (!FIRCLSFileInitWithPath(&file, storage->incrementalPath, true)) {
    FIRCLSSDKLogError("Unable to open k-v file\n");
    return;
  }

  FIRCLSUserLoggingWriteKVEntriesToFile(keysAndValues, true, &file);
  FIRCLSFileClose(&file);

  *counter += keysAndValues.count;
  if (*counter >= storage->maxIncrementalCount || containsNullValue) {
    dispatch_async(FIRCLSGetLoggingQueue(), ^{
      FIRCLSUserLoggingCompactKVEntries(storage);
      *counter = 0;
    });
  }
}

NSArray *FIRCLSUserLoggingStoredKeyValues(const char *path) {
  if (!FIRCLSContextIsInitialized()) {
    FIRCLSSDKLogWarn(
        "Failed to write key/value pair. Crashlytics context has not initialized yet.\n");
    return nil;
  }

  return FIRCLSFileReadSections(path, true, ^NSObject *(id obj) {
    return [obj objectForKey:@"kv"];
  });
}

#pragma mark - NSError Logging
static void FIRCLSUserLoggingRecordErrorUserInfo(FIRCLSFile *file,
                                                 const char *fileKey,
                                                 NSDictionary<NSString *, id> *userInfo) {
  if ([userInfo count] == 0) {
    return;
  }

  FIRCLSFileWriteHashKey(file, fileKey);
  FIRCLSFileWriteArrayStart(file);

  for (id key in userInfo) {
    id value = [userInfo objectForKey:key];
    if (![value respondsToSelector:@selector(description)]) {
      continue;
    }


Review comment (bug):
```suggestion
        "Failed to read key/value pair. Crashlytics context has not initialized yet.\n");
```

Code after:
  if (!FIRCLSIsValidPointer(storage) || !FIRCLSIsValidPointer(counter)) {
    FIRCLSSDKLogError("Bad parameters\n");
    return;
  }

  if (!FIRCLSFileInitWithPath(&file, storage->incrementalPath, true)) {
    FIRCLSSDKLogError("Unable to open k-v file\n");
    return;
  }

  FIRCLSUserLoggingWriteKVEntriesToFile(keysAndValues, true, &file);
  FIRCLSFileClose(&file);

  *counter += keysAndValues.count;
  if (*counter >= storage->maxIncrementalCount || containsNullValue) {
    dispatch_async(FIRCLSGetLoggingQueue(), ^{
      FIRCLSUserLoggingCompactKVEntries(storage);
      *counter = 0;
    });
  }
}

NSArray *FIRCLSUserLoggingStoredKeyValues(const char *path) {
  if (!FIRCLSContextIsInitialized()) {
    FIRCLSSDKLogWarn(
        "Failed to read key/value pairs. Crashlytics context has not initialized yet.\n");
    return nil;
  }

  return FIRCLSFileReadSections(path, true, ^NSObject *(id obj) {
    return [obj objectForKey:@"kv"];
  });
}

#pragma mark - NSError Logging
static void FIRCLSUserLoggingRecordErrorUserInfo(FIRCLSFile *file,
                                                 const char *fileKey,
                                                 NSDictionary<NSString *, id> *userInfo) {
  if ([userInfo count] == 0) {
    return;
  }

  FIRCLSFileWriteHashKey(file, fileKey);
  FIRCLSFileWriteArrayStart(file);

  for (id key in userInfo) {
    id value = [userInfo objectForKey:key];
    if (![value respondsToSelector:@selector(description)]) {
      continue;
    }