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 EXC_BAD_ACCESS crash by null-checking proper error #1116

Merged
merged 1 commit into from
Oct 4, 2019
Merged

Prevent EXC_BAD_ACCESS crash by null-checking proper error #1116

merged 1 commit into from
Oct 4, 2019

Conversation

ericbomgardner
Copy link
Contributor

Problem

If writing a screenshot fails due to failure to create a directory, an error is assigned to the error parameter. However, when writeScreenShotForLine:... is called with a NULL error param by writeScreenshotForException: in XCTestCase-KIFAdditions.m, the assignment causes a crash with EXC_BAD_ACCESS.

Relevant excerpt from XCTestCase-KIFAdditions.m:

[[UIApplication sharedApplication] writeScreenshotForLine:[exception.userInfo[@"LineNumberKey"] unsignedIntegerValue] inFile:exception.userInfo[@"FilenameKey"] description:nil error:NULL];

This regression was introduced by commit f4705fb (#981), which changed the error checked by the if (error) { ... } check away from error.

Fix

Revert f4705fb -- check proper error again.

This parallels all the other if (error) checks in writeScreenShotForLine:....

QA Plan

  • Confirm that crash no longer occurs when writing a screenshot fails due to failure to create a directory
  • Confirm that behavior is acceptable when directoryCreationError is nil:
    • When simulating a nil directoryCreationError, result of printing error: Error Domain=KIFTest Code=0 "Couldn't create directory at path $CIRCLE_ARTIFACTS (details: (null))" UserInfo={NSLocalizedDescription=Couldn't create directory at path $CIRCLE_ARTIFACTS (details: (null))}

@justinseanmartin
Copy link
Contributor

Thanks for the contribution!

@justinseanmartin justinseanmartin merged commit 8a53f36 into kif-framework:master Oct 4, 2019
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.

2 participants