Skip to content

Commit

Permalink
Fix for the UBSan issue reported in #362.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdoe committed Nov 4, 2018
1 parent 662bbeb commit d00d8f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/OCMock/OCPartialMockObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ - (void)setupForwarderForSelector:(SEL)sel
return;

Method originalMethod = class_getInstanceMethod(mockedClass, sel);
IMP originalIMP = method_getImplementation(originalMethod);
const char *types = method_getTypeEncoding(originalMethod);
/* Might be NULL if the selector is forwarded to another class */
IMP originalIMP = (originalMethod != NULL) ? method_getImplementation(originalMethod) : NULL;
const char *types = (originalMethod != NULL) ? method_getTypeEncoding(originalMethod) : NULL;
// TODO: check the fallback implementation is actually sufficient
if(types == NULL)
types = ([[mockedClass instanceMethodSignatureForSelector:sel] fullObjCTypes]);
Expand Down

0 comments on commit d00d8f3

Please sign in to comment.