Permalink
Browse files

When comparing message, require them to have the same descriptor.

This will cover someone subclassing the message, and also handles
something crazy like someone comparing to a raw NSObject.
  • Loading branch information...
thomasvl committed Nov 3, 2017
1 parent cbe2505 commit 1f57e540accbb36f350da3e8f341e67ab0188de9
Showing with 4 additions and 3 deletions.
  1. +4 −3 objectivec/GPBMessage.m
View
@@ -2591,13 +2591,14 @@ - (BOOL)isEqual:(id)other {
if (other == self) {
return YES;
}
if (![other isKindOfClass:[self class]] &&
![self isKindOfClass:[other class]]) {
if (![other isKindOfClass:[GPBMessage class]]) {
return NO;
}
GPBMessage *otherMsg = other;
GPBDescriptor *descriptor = [[self class] descriptor];
if ([[otherMsg class] descriptor] != descriptor) {
return NO;
}
uint8_t *selfStorage = (uint8_t *)messageStorage_;
uint8_t *otherStorage = (uint8_t *)otherMsg->messageStorage_;

0 comments on commit 1f57e54

Please sign in to comment.