aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/GPBUtilities.m
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2017-01-04 15:03:42 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2017-01-05 09:15:40 -0500
commit988ffe0a78ebda0410e61ce31a3bd689c774f59e (patch)
treef5e92cdc634e4eef2ef2b891de95ad23bec3fba4 /objectivec/GPBUtilities.m
parent4cb113a91b180559f0eedbca0244ef1181a7204c (diff)
Minor fix for autocreated object repeated fields and maps.
- If setting/clearing a repeated field/map that was objects, check the class before checking the autocreator. - Just to be paranoid, don’t mutate within copy/mutableCopy for the autocreated classes to ensure there is less chance of issues if someone does something really crazy threading wise. - Some more tests for the internal AutocreatedArray/AutocreatedDictionary classes to ensure things are working as expected. - Add Xcode 8.2 to the full_mac_build.sh supported list.
Diffstat (limited to 'objectivec/GPBUtilities.m')
-rw-r--r--objectivec/GPBUtilities.m16
1 files changed, 10 insertions, 6 deletions
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m
index d4538598..68aadb77 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -408,9 +408,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
if (field.fieldType == GPBFieldTypeRepeated) {
// If the old array was autocreated by us, then clear it.
if (GPBDataTypeIsObject(fieldType)) {
- GPBAutocreatedArray *autoArray = oldValue;
- if (autoArray->_autocreator == self) {
- autoArray->_autocreator = nil;
+ if ([oldValue isKindOfClass:[GPBAutocreatedArray class]]) {
+ GPBAutocreatedArray *autoArray = oldValue;
+ if (autoArray->_autocreator == self) {
+ autoArray->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Array.
@@ -423,9 +425,11 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
// If the old map was autocreated by us, then clear it.
if ((field.mapKeyDataType == GPBDataTypeString) &&
GPBDataTypeIsObject(fieldType)) {
- GPBAutocreatedDictionary *autoDict = oldValue;
- if (autoDict->_autocreator == self) {
- autoDict->_autocreator = nil;
+ if ([oldValue isKindOfClass:[GPBAutocreatedDictionary class]]) {
+ GPBAutocreatedDictionary *autoDict = oldValue;
+ if (autoDict->_autocreator == self) {
+ autoDict->_autocreator = nil;
+ }
}
} else {
// Type doesn't matter, it is a GPB*Dictionary.