`GREYElementMatcherBlock` not respecting that `item` can be nil.
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 5.7k
- Forks
- 737
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 5
Description
[GREYBaseMatcher](https://github.com/google/EarlGrey/blob/1d507003e3c436c2db89d0945e3d23f7bf25ac2b/EarlGrey/Matcher/GREYBaseMatcher.h) indicates that the element passed to `- (BOOL)matches:(_Nullable id)item;` can be null. However [GREYElementMatcherBlock](https://github.com/google/EarlGrey/blob/1d507003e3c436c2db89d0945e3d23f7bf25ac2b/EarlGrey/Matcher/GREYElementMatcherBlock.m) defines `MatchesBlock` with a non-null item and does not check the item for nil before calling the block. This results in `EXEC_BAC_ACCESS` when using Swift on Xcode 9.3.
`GREYElementMatcherBlock.m` should change its `matches` method to:
```Objective-C
- (BOOL)matches:(id)item {
if (!item) return NO;
return _matcherBlock(item);
}
```
I'm sorry that I didn't create a PR. I discovered this at work and I have to go through an open source review process to submit a PR. It looks like 1.14.0 is close to being released and getting through my works approval process takes a long time.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open EarlGrey/Matcher/GREYElementMatcherBlock.m and inspect the matches: method and its MatchesBlock definition. Confirm that a nil item is handled without invoking the block and returns NO, while non-nil matching still behaves as before.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, objective-c
- Domain
- mobile-dev, testing-qa
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100