Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash in findMatchingSimulator #59

Merged
merged 1 commit into from
Jan 11, 2019
Merged

Prevent crash in findMatchingSimulator #59

merged 1 commit into from
Jan 11, 2019

Conversation

zubko
Copy link
Contributor

@zubko zubko commented Dec 29, 2018

findMatchingSimulator could crash if the simulator's name is custom (renamed in Xcode) for ex: iPhone6v11.

After this fix it doesn't crash and the correct custom named simulator is chosen.

Copy link
Member

@grabbou grabbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting this PR! I left a comment to help us get through the review process :)

@@ -31,7 +31,7 @@ function findMatchingSimulator(simulators, simulatorString) {
const parsedSimulatorName = simulatorString
? simulatorString.match(/(.*)? (?:\((.*)?\))?/)
: [];
if (parsedSimulatorName[2] !== undefined) {
if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting.

On line 31, we make sure it's either a matched value or an array - it shouldn't be "undefined" at all.

Could you provide more details when this would be null, or causing a crash?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.match() may return null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it confused me:

simulatorString
    ? simulatorString.match(/(.*)? (?:\((.*)?\))?/)
    : [];

Thought we check on simulator.match instead xd

@@ -31,7 +31,7 @@ function findMatchingSimulator(simulators, simulatorString) {
const parsedSimulatorName = simulatorString
? simulatorString.match(/(.*)? (?:\((.*)?\))?/)
: [];
if (parsedSimulatorName[2] !== undefined) {
if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.match() may return null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants