Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix a crash in the snapshot callback #773

Merged
merged 2 commits into from
Oct 18, 2018
Merged

Conversation

pinkfish
Copy link
Contributor

@pinkfish pinkfish commented Sep 7, 2018

The following code causes the snapshot variable to be nil in the callback path. However the code assumes it is not nil and crashes :)

  • (id)
    addSnapshotListenerInternalWithOptions:(FSTListenOptions *)internalOptions
    listener:(FIRDocumentSnapshotBlock)listener {
    FIRFirestore *firestore = self.firestore;
    FSTQuery *query = [FSTQuery queryWithPath:self.key.path()];
    const DocumentKey key = self.key;

    FSTViewSnapshotHandler snapshotHandler = ^(FSTViewSnapshot *snapshot, NSError *error) {
    if (error) {
    listener(nil, error);
    ret

@pinkfish
Copy link
Contributor Author

pinkfish commented Sep 7, 2018

Here is the original bug report:
flutter/flutter#21537

@kroikie kroikie self-assigned this Sep 10, 2018
@pinkfish
Copy link
Contributor Author

pinkfish commented Oct 3, 2018

Ping? Looks like this is still broken?

@illia-romanenko
Copy link

I can confirm that this helps - just patched firestore plugin myself on my local machine with changes from @pinkfish and app worked fine without crash producing nice error messages! I think we need to merge this asap!

solid-software pushed a commit to solid-software/plugins that referenced this pull request Oct 15, 2018
pinkfish and others added 2 commits October 18, 2018 09:43
The following code causes the snapshot variable to be nil in the callback path.  However the code assumes it is not nil and crashes :)

- (id<FIRListenerRegistration>)
addSnapshotListenerInternalWithOptions:(FSTListenOptions *)internalOptions
                              listener:(FIRDocumentSnapshotBlock)listener {
  FIRFirestore *firestore = self.firestore;
  FSTQuery *query = [FSTQuery queryWithPath:self.key.path()];
  const DocumentKey key = self.key;

  FSTViewSnapshotHandler snapshotHandler = ^(FSTViewSnapshot *snapshot, NSError *error) {
    if (error) {
      listener(nil, error);
      ret
@kroikie
Copy link
Contributor

kroikie commented Oct 18, 2018

@pinkfish Thanks for this PR. @illia-romanenko thanks for confirming.

@kroikie kroikie merged commit 8102ea7 into flutter:master Oct 18, 2018
@pinkfish pinkfish deleted the patch-1 branch October 18, 2018 21:56
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
* Fix a crash in the snapshot callback
andreidiaconu added a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
solid-vovabeloded pushed a commit to solid-software/plugins that referenced this pull request Nov 12, 2019
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
* Fix a crash in the snapshot callback
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants