Skip to content

Commit 52476cc

Browse files
Nick Gravelynerikdoe
authored andcommitted
Fixing crashes by adding asserts for nil parameters when creating mocks.
1 parent 3f88a5d commit 52476cc

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

Source/OCMock/OCClassMockObject.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ @implementation OCClassMockObject
2626

2727
- (id)initWithClass:(Class)aClass
2828
{
29+
NSParameterAssert(aClass != nil);
2930
[super init];
3031
mockedClass = aClass;
3132
[self prepareClassForClassMethodMocking];

Source/OCMock/OCPartialMockObject.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ @implementation OCPartialMockObject
2929

3030
- (id)initWithObject:(NSObject *)anObject
3131
{
32+
NSParameterAssert(anObject != nil);
3233
[self assertClassIsSupported:[anObject class]];
3334
[super initWithClass:[anObject class]];
3435
realObject = [anObject retain];

Source/OCMock/OCProtocolMockObject.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ @implementation OCProtocolMockObject
2424

2525
- (id)initWithProtocol:(Protocol *)aProtocol
2626
{
27+
NSParameterAssert(aProtocol != nil);
2728
[super init];
2829
mockedProtocol = aProtocol;
2930
return self;

0 commit comments

Comments
 (0)