Prevent EXC_BAD_ACCESS crash by null-checking proper error #1116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If writing a screenshot fails due to failure to create a directory, an error is assigned to the
error
parameter. However, whenwriteScreenShotForLine:...
is called with aNULL
error param bywriteScreenshotForException:
in XCTestCase-KIFAdditions.m, the assignment causes a crash with EXC_BAD_ACCESS.Relevant excerpt from XCTestCase-KIFAdditions.m:
KIF/Additions/XCTestCase-KIFAdditions.m
Line 67 in 0ea470b
This regression was introduced by commit f4705fb (#981), which changed the error checked by the
if (error) { ... }
check away fromerror
.Fix
Revert f4705fb -- check proper error again.
This parallels all the other
if (error)
checks inwriteScreenShotForLine:...
.QA Plan
directoryCreationError
is nil:nil
directoryCreationError
, result of printingerror
: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))}