aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2017-11-03 12:49:28 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2017-11-03 12:49:28 -0400
commit1f57e540accbb36f350da3e8f341e67ab0188de9 (patch)
tree8bfeca5585036b9965aad5df6ce95bca86f82815 /objectivec
parentcbe250591fca9d2e776776be065a72c5550a5556 (diff)
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.
Diffstat (limited to 'objectivec')
-rw-r--r--objectivec/GPBMessage.m7
1 files changed, 4 insertions, 3 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index 37cff6ce..afe39c1e 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -2591,13 +2591,14 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
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_;