Skip to content

Commit c1fc8d0

Browse files
committed
Address static analyzer warning in OCPartialMockObject
* Issue #543 about potential nil passed to class_addMethod() OCPartialMockObject#setupForwarderForSelector * Modified to just return if there is no existing implementation for the method
1 parent 7f6e9e9 commit c1fc8d0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Source/OCMock/OCPartialMockObject.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ - (void)setupForwarderForSelector:(SEL)sel
206206
Method originalMethod = class_getInstanceMethod(mockedClass, sel);
207207
/* Might be NULL if the selector is forwarded to another class */
208208
IMP originalIMP = (originalMethod != NULL) ? method_getImplementation(originalMethod) : NULL;
209+
if(originalIMP == NULL)
210+
return;
211+
209212
const char *types = (originalMethod != NULL) ? method_getTypeEncoding(originalMethod) : NULL;
210213
// TODO: check the fallback implementation is actually sufficient
211214
if(types == NULL)

0 commit comments

Comments
 (0)